CodeMama Posted April 23, 2009 Share Posted April 23, 2009 ??? trying to list all records but only getting the last record? <?php $result=mysql_query("select * from entrySub order by entryNum asc"); while($row=mysql_fetch_assoc($result)){ ?> <?php $row=mysql_fetch_assoc($result); // make one record out. ?> <p> <a href="#" id="slick-show"><?php echo $row['nurseName']; ?></a> <a href="#" id="slick-hide">Hide <?php echo $row['nurseName']; ?></a> <a href="#" id="slick-toggle">Toggle the box</a></p> <div id="slickbox"> <table> <tr> <td>Entry Number: <?php echo $row['entryNum']; ?></td> <td><?php echo $row['entryDate']; ?></td> </tr> <tr> <td>Employer:<?php echo $row['nurseEmployer'];?></td> <td>Address: <?php echo $row['nurseAddress']; ?></td> </tr> </table> </div> <? } // End loops. ?> Link to comment https://forums.phpfreaks.com/topic/155375-solved-my-loop-isnt-looping/ Share on other sites More sharing options...
Maq Posted April 23, 2009 Share Posted April 23, 2009 Why do you call this twice, once with a loop and once without? Get right of: Also, never use short tags () always use <?php. Link to comment https://forums.phpfreaks.com/topic/155375-solved-my-loop-isnt-looping/#findComment-817478 Share on other sites More sharing options...
mikesta707 Posted April 23, 2009 Share Posted April 23, 2009 You may want to use mysql_result instead of fetch_assoc something like the following $result=mysql_query("select * from entrySub order by entryNum asc"); $num = mysql_num_rows($result) $i = 0; while ($i < $num){ $nurseName = mysql_result($result, $i, 'nurseName'); .... etc. } the first parameter of mysql_result is a valid mysql result, the second parameter is the row number of the returned result, and the third parameter is the column name. hope that helped Link to comment https://forums.phpfreaks.com/topic/155375-solved-my-loop-isnt-looping/#findComment-817489 Share on other sites More sharing options...
CodeMama Posted April 23, 2009 Author Share Posted April 23, 2009 Thanks!! Link to comment https://forums.phpfreaks.com/topic/155375-solved-my-loop-isnt-looping/#findComment-817513 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.