Jump to content

[SOLVED] My loop isn't Looping..


CodeMama

Recommended Posts

??? 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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.