vendredi 24 juillet 2015

php while loop if to do for first row else to do for second row?

I have while loop from mysql , i try to do some thing for first result under if else do other thing for second result etc....

my code this

$i = 1;
while($row = mysql_fetch_array($get_row)) {
$rowid = $row['rowid'];
$number = $row['number'];
$result = $number - 1;
if ($result != '0') {
// for only first result != 0 do this
require('result.php');
$i++;
// for all other results != 0 too do this
$edit_row = "UPDATE rows SET status = 'Ok' WHERE rowid = '$rowid'";
mysql_query($edit_row);
} elseif ($result == '0') {
$edit_row = "UPDATE rows SET status = 'Not Ok' WHERE rowid = '$rowid'";
mysql_query($edit_row);
} 
}

Aucun commentaire:

Enregistrer un commentaire