Jump to content


Photo

MySQL Not Returning the First Row


  • Please log in to reply
1 reply to this topic

#1 llcooljayce

llcooljayce
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 21 July 2006 - 05:04 PM

Hey guys, here's my code:

<html>
  <head>
    <title>Completed RSVPs</title>
  </head>
  <body>
  <center>
  <table border="1">
  <tr>
  <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>
  </tr>

<?

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)) {
$count++;
$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>';
if($ceremony=="0")
  echo '<td align="center">No</td>';
else
echo '<td align="center">Yes</td>';
echo '<td align="center">'.$adult_ceremony.'</td>';
echo '<td align="center">'.$child_ceremony.'</td>';
if($reception=="0")
  echo '<td align="center">No</td>';
else
echo '<td align="center">Yes</td>';
echo '<td align="center">'.$adult_reception.'</td>';
echo '<td align="center">'.$child_reception.'</td>';
echo '</tr>';
}
?>
</table>
</center>
</body>
</html>

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?


#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 July 2006 - 07:49 PM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users