Need help on coding problem

From: Date: Thu, 23 Nov 2000 19:08:29 +0000
Subject: Need help on coding problem
Groups: php.general 
Request: Send a blank email to php-general+get-26856@lists.php.net to get a copy of this message
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 ---

« previous php.general (#26856) next »