RE: Need help on coding problem
| From: | Tim Ward | Date: | Wed, 29 Nov 2000 09:17:42 +0000 |
| Subject: | RE: Need help on coding problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27793@lists.php.net to get a copy of this message | ||
Why do you want to jump back to the beginning of the loop ... it's going
there anyway without executing any more code (or is there something missing
from your code). If there is some code missing surely 'continue' would jump
over it? The only way I can see that 'continue wouldn't work would be if you
wanted to process the same row again rather than the next one. In this case
you need another loop inside the row-getting loop.
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Oliver Ertl [mailto:oliver@ertl.co.za]
> Sent: 23 November 2000 19:08
> To: php-general@lists.php.net
> Subject: Need help on coding problem
>
>
> I use PHP 4.0.3
>
> Hi,
>
> i have got a problem with a small script. Maybe you can help me.
> The year and month came from a database field wich is a
> Unix-Timestamp.
> For example here are some values for year and month:
>
> $year $month
> 2000 11
> 2000 11
> 2000 10
> 2000 9
> 1999 10
> 1998 8
>
> The output should be:
> 2000: 9 10 11
> 1999: 10
> 1998: 8
>
> I think the problem is at where I need to jump to the beginning of the
> while statement. I hope you can correct the code for me or
> give me some
> hints.
>
> --- Code start ---
> $jahr = 0;
> $monat = 0;
>
> while ( $row = mysql_fetch_array ( $sql_result )) {
> $db_timestamp = $row[timestamp];
> $jahrtemp = date ( "Y", $db_timestamp );
> $monattemp = date ( "m", $db_timestamp );
>
> if ( $monat == $monattemp ) {
> if ( $jahr == $jahrtemp ) {
> // problem is here, i need to jump to the begin of the while
> statement
> } else {
> $jahr = $jahrtemp;
> }
> } else {
> if ( $jahr == $jahrtemp ) {
> $monat = $monattemp;
> } else {
> $jahr = $jahrtemp;
> $monat = $monattemp;
> echo "$jahr, $monat<br>";
> }
> }
> }
> --- Code end ---
>