$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'];
...
...
...
...
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
$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)
{
while ($row = mysql_fetch_array($result))
{
$name = $rowї'name'];
...
}
}
Using mysql_fetch_array returns either an array of all your fields in the table or FALSE if there are no more rows to recover.
mysql_fetch_array uses it's own internal counter to sift through the results that's why you can use $row['name'] to retrieve the content of the field named 'name', each time mysql_fetch_array is called it increments it's internal counter and populates $row with the next row's values...