Hi there,
Why is it that when I try fetching an array from the same db query result through two different while loops on one page it doesn't work.
Here's an example of what I'm trying to do:
<?
$result = mysql_db_query($db, "SELECT country FROM registration where approved='y' group by country order by country asc");
?>
<html>
<body>
<form>
<?
while($form_array=mysql_fetch_array($result)){
print "<option value=\"#$form_array[country]\">$form_array[country]";
};
?>
</form>
<br />
<?
while($rst_array=mysql_fetch_array($result)){
print "<tr><td valign=\"top\"><font face=\"verdana, arial, helvetica, sans-serif\" size=\"2\"><b><a name=\"$rst_array[country]\">$rst_array[country]</a></b>";
};
?>
</body>
</html>
For some reason, when I try fetching an array from the same variable $result, the second while statement doesn't run - even though the variables with the array results are different names: $form_array and $rst_array.
I did fix this problem by simply duplicating $result and naming it $form_result and then using $form_result in the first while statement and $result in the second.
So my question is, am I missing something? Does anyone know why this is happening and is there a better solution out there?
Thank you, Shawna