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. ?> Quote 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. Quote 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 Quote 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!! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.