Mysql_fetch_assoc - Looping thru result sets
Posted: Mon Aug 19, 2002 9:15 pm
Can anyone tell me why this doesn't display two tables? The first table and
result set shows up, but the secong table does not appear. I have tried
resetting $allhotels but that gives me an error.
---Code----
<?
$allhotels_query = "select ID, hot_cod from hotelbkg order by hot_cod";
$allhotels = mysql_query($allhotels_query) or
die (mysql_error());
?>
<form method="post" action="<?$PHP_SELF?>">
<table border="1">
<?
while ($row = mysql_fetch_assoc($allhotels)){
?>
<tr>
<td><input name="bkg_ref" value="<?echo $row["hot_cod"]?>"></td>
<td><input name="ID" value="<?echo $row["ID"]?>"></td>
</tr>
<?}?>
</table>
<table border="1">
<?
reset($allhotels);
while ($row = mysql_fetch_assoc($allhotels)){
?>
<tr>
<td><input name="bkg_ref" value="<?echo $row["hot_cod"]?>"></td>
<td><input name="ID" value="<?echo $row["ID"]?>"></td>
</tr>
<?}?>
</table>
</form>
---Finish Code---
Thanks, Mark
result set shows up, but the secong table does not appear. I have tried
resetting $allhotels but that gives me an error.
---Code----
<?
$allhotels_query = "select ID, hot_cod from hotelbkg order by hot_cod";
$allhotels = mysql_query($allhotels_query) or
die (mysql_error());
?>
<form method="post" action="<?$PHP_SELF?>">
<table border="1">
<?
while ($row = mysql_fetch_assoc($allhotels)){
?>
<tr>
<td><input name="bkg_ref" value="<?echo $row["hot_cod"]?>"></td>
<td><input name="ID" value="<?echo $row["ID"]?>"></td>
</tr>
<?}?>
</table>
<table border="1">
<?
reset($allhotels);
while ($row = mysql_fetch_assoc($allhotels)){
?>
<tr>
<td><input name="bkg_ref" value="<?echo $row["hot_cod"]?>"></td>
<td><input name="ID" value="<?echo $row["ID"]?>"></td>
</tr>
<?}?>
</table>
</form>
---Finish Code---
Thanks, Mark