displaying data only on the first time through a loop.
Posted: Mon Jun 27, 2005 12:57 pm
I want to display a header on a loop only if the conditional is true and only on the first pass through. Below is the code that I used. Do I have something in the wrong place? This seems to set off an infinite loop.
Thanks in advance!
Code: Select all
$query = "select * from offices where siteid = $siteid";
$query_result = mysql_query($query) or die(mysql_error());
$i=0;
while($row = mysql_fetch_array($query_result)) {
while($i < 1) {
print "<p><strong>Office locations: </strong></p>";
}
print "<p>{$row[1]}, {$row[2]}</p>";
if (!empty($row[3])) {
print "<p>{$row[3]}</p>";
}
$i++;
}