[thelist] PHP - mysql_fetch_array
Peter Duchateau
peter at duo.be
Thu Aug 1 05:07:10 CDT 2002
I want to loop twice over the result of my sql query.
1) show all agents for North America
2) show all agents for South America
I never get any agents in the second loop ?
<?
// include database connection
require("../../../includes/db_connection.php");
$lang = "nl";
$sql = "select c.country_id, c.name_" .$lang . " as country, c.region_id " .
"from agents a, countries c " .
"where a.country_id = c.country_id " .
"and a.duiven = 'Y' " .
"group by c.country_id, c.name_" .$lang . " " .
"order by c.region_id, c.name_" .$lang;
//echo $sql;
$countries = mysql_query($sql, $connection) or die("Error in query: " .
mysql_error());
?>
...
<table width="560" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top">
<table border="0" width="90">
<tr><td bgcolor="#BB1717" class="continent">North America</td></tr>
<? while ($myrow = mysql_fetch_array($countries)) {
if ($myrow["region_id"] == 1) { ?>
<tr><td class="landen"><a href="detail_land.php?country_id=<?=
$myrow["country_id"]; ?>"><?= $myrow["country"]; ?></a></td></tr>
<? }
} ?>
</table>
</td>
<td valign="top">
<table border="0" width="90">
<tr><td bgcolor="#BB1717" class="continent">South America</td></tr>
<? while ($myrow = mysql_fetch_array($countries)) {
if ($myrow["region_id"] == 2) { ?>
<tr><td class="landen"><a href="detail_land.php?country_id=<?=
$myrow["country_id"]; ?>"><?= $myrow["country"]; ?></a></td></tr>
<? }
} ?>
</table>
</td>
</tr>
</table>
...
More information about the thelist
mailing list