I am having trouble using my queries in for loops more then once, for instance.
$query = "select title, author from books";
$result = mysql_db_query($db,$query,$connection);
$records = mysql_num_rows($result);
$row = mysql_fetch_row($result);
this for loop works:
<tr>
<?
for ($a=0; $a<$records; $a++)
{
$row = mysql_fetch_array($result);
echo "<td>".$row[0]."</td>";
}
?>
</tr>
But when I try this loop right after it, it does not work, all the cells are empty, but it is the correct number...
<tr>
<?
for ($a=0; $a<$records; $a++)
{
$row = mysql_fetch_array($result);
echo "<td>".$row[1]."</td>";
}
?>
</tr>
this code will print a row with all the titles
then a row with blanks
I can swith the array row[0] and row[1] and it will print a row of authors then a row of blanks, so I know it is getting the data,
what I have been doing as a work around is running the query again with a different variable, like $row, $row2, $row3, etc....what the heck am I doing wrong?