I need to display the results of a query twice on one page and have run into a problem. I have used mysql_data_seek at the end of the first do while loop, setting the internal pointer back to 0, but when I echo out the results a second time I get a blank record at the top.
You can see the results on a test page at http://elsombrero.stacnz.com/testing.php, the code is:
$courses_sql = "SELECT * FROM courses";
$courses_query = mysql_query($courses_sql) or die(mysql_error());
$rsCourses = mysql_fetch_assoc($courses_query);
<ul><?php
do {
?>
<li><a href="menu.php?courseID=<?php echo $rsCourses['courseID']; ?>">
<?php echo $rsCourses['cName']; ?>
</a></li>
<?php
} while ($rsCourses = mysql_fetch_assoc($courses_query));
mysql_data_seek($courses_query, 0);
?>
<?php
do {
?>
<li><a href="menu.php?courseID=<?php echo $rsCourses['courseID']; ?>">
<?php echo $rsCourses['cName']; ?>
</a></li>
<?php
} while ($rsCourses = mysql_fetch_assoc($courses_query));
mysql_data_seek($courses_query, 0);
?></ul>
</html>