mysql loop through table
Posted: Mon Jan 20, 2003 12:58 pm
hi all, I have a piece of php-code which I don't understand (it works though):
the code goes on but this is the important part
how does $row know which item inside the array it should pick? I mean: there are more rows in the tableand it loops through the table, what is the point of th $i in the for loop if it's not even used?
I would have expected this: $name = $row[$]['name'] instead of the current line
Steve
Code: Select all
$query = "SELECT * FROM guests ORDER BY id DESC";
$result = @mysql_query($query) or die("&error=".mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows > 0){
for($i = 0; $i < $num_rows; $i++)
{
$row = mysql_fetch_array($result);
$name = $rowї'name'];
...
...
...
...how does $row know which item inside the array it should pick? I mean: there are more rows in the tableand it loops through the table, what is the point of th $i in the for loop if it's not even used?
I would have expected this: $name = $row[$]['name'] instead of the current line
Steve