I do a mySQL query to get some data and then (for the purpose of debugging) print it out. In this particular sample there are 5 rows of data and each room_id in the database table has a value. However the print-out only shows the room_id of the first row.
$query_rooms = "SELECT room_id FROM lh_rooms WHERE hid = '$hid'";
$rooms = mysql_query($query_rooms, $MySQL) or die(mysql_error());
$row_rooms = mysql_fetch_assoc($rooms);
$numrows = mysql_num_rows($rooms);
$i = 0;
while ($i < $numrows) {
$room_id=$row_rooms['room_id'][$i];
echo $i." - ".$room_id."<br><br>";
++$i;
}
0 - 2
1 -
2 -
3 -
4 -
Can someone explain what is happening
mysql_xxx()functions are obsolete. See also Why shouldn't I use mysql_* functions in PHP? for more infomysqllibrary has been considered obsolete for over a decade already. It throws formal deprecation notices in the current supported PHP versions, and is being dropped entirely in the next version (PHP7.0, release later this month). More importantly, it many features in recent mySQL versions are unsupported, including secure communications between the DB and the client. Continue using at your own risk