I have a webpage that builds an html table if there is any data in a mySQL table. That works fine, the html table is populated with data from the mySQL table. My problem is when there is data it populates the html table but lists the first mySQL table entry twice in the html table. I do not have any idea why this happens.
Here's the relevant code:
$PNDG_USRS_S1 = mysql_query("SELECT * FROM `sql_table`");
$PNDG_USRS = mysql_fetch_assoc($PNDG_USRS_S1);
if (mysql_num_rows($PNDG_USRS_S1 = mysql_query("SELECT * FROM `sql_table`")) > 0) {
?>
<table id="table">
<tr>
<td class='block_title'>
Name
</td>
<td class='block_title'>
Email
</td>
<td class='block_title'>
Grade
</td>
<td class='block_title'>
Gender
</td>
<td class='block_title'>
Birthday
</td>
<td class='block_title'>
Accept?
</td>
</tr>
<?php
do {
?>
<tr>
<td>
<?php echo $PNDG_USRS['Name']; ?>
</td>
<td>
<?php echo $PNDG_USRS['email']; ?>
</td>
<td>
<?php echo $PNDG_USRS['grade']; ?>
</td>
<td>
<?php echo $PNDG_USRS['Gender']; ?>
</td>
<td>
<?php if ($PNDG_USRS['birthdate'] == "0000-00-00") {echo "N/A";}else{echo $PNDG_USRS['birthdate'];}; ?>
</td>
<td>
<a href='<?php echo $_SESSION['RP'], "/admin/?state=USR_VRFY&usr_id=", $PNDG_USRS['ID']; ?>' onclick="return confirm('Are you sure you want to verify the user <?php echo $PNDG_USRS['Name']; ?> and make them an active user?');">Verify User?</a>
</td>
</tr>
<?php
} while ($PNDG_USRS = mysql_fetch_assoc($PNDG_USRS_S1));
?>
</table>
<?php
} else {
?>
<center>
<div id='MSG'>
No users pending approval
</div>
</center>
<?php
};
};
};
The page is designed to list all new users on a website. An administrator or moderator must confirm each user before they have access, that's what this page will be used for.
Thanks in advanced! The new school year is starting and we will have a large number of new users soon so I'd like to have this form working soon. Again, thanks!