Jump to content


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


MySQL Not Returning the First Row

Recommended Posts

Hey guys, here's my code:

    <title>Completed RSVPs</title>
  <table border="1">
  <td align="center"><b>Count</b></td>
  <td align="center"><b>First Name</b></td>
  <td align="center"><b>Last Name</b></td>
  <td align="center"><b>Attending Ceremony</b></td>
  <td align="center"><b>Adults</b></td>
  <td align="center"><b>Kids</b></td>
  <td align="center"><b>Attending Reception</b></td>
  <td align="center"><b>Adults</b></td>
  <td align="center"><b>Kids</b></td>


require 'inc/db_connect.php';

$sql = 'select * from verify where complete=1 order by lname, fname';
$result = mysql_query($sql);
$row = mysql_fetch_array($result, MYSQL_BOTH);
$count = 0;

while ($row = mysql_fetch_array($result)) {
$fname = $row['fname'];
$lname = $row['lname'];
$ceremony = $row['attending_ceremony'];
$adult_ceremony = $row['adult_ceremony'];
$child_ceremony = $row['child_ceremony'];
$reception = $row['attending_reception'];
$adult_reception = $row['adult_reception'];
$child_reception = $row['child_reception'];

echo '<tr>';
echo '<td align="center">'.$count.'</td>';
echo '<td align="center">'.$fname.'</td>';
echo '<td align="center">'.$lname.'</td>';
  echo '<td align="center">No</td>';
echo '<td align="center">Yes</td>';
echo '<td align="center">'.$adult_ceremony.'</td>';
echo '<td align="center">'.$child_ceremony.'</td>';
  echo '<td align="center">No</td>';
echo '<td align="center">Yes</td>';
echo '<td align="center">'.$adult_reception.'</td>';
echo '<td align="center">'.$child_reception.'</td>';
echo '</tr>';

I don't know why but the 'while ($row = mysql_fetch_array($result)) { ' clause doesn't seem to return the first row of the results ... any ideas why?

Share this post

Link to post
Share on other sites
Of course it doesn't... you've issued a previous call to mysql_fetch_array() a few lines earlier, for no apparent reason, so the row iterator has already been incremented by 1.

Share this post

Link to post
Share on other sites


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.