Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.