Jump to content

while($row = mysql_fetch_array($result)) isn't returning final record


DVigneault

Recommended Posts

Hey all--

 

Here's the setup: I'm joining two tables and then using while($row = mysql_fetch_array($result)) to echo the resulting records into an HTML table.  But only 15 of the 16 records are showing up.  If I delete one record, I get 14 out of 15.  The one to not show up is always the latest record.

 

<?php

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("atsband", $con);
$query = "SELECT some fields of table 1 and table 2 FROM table 1 LEFT JOIN table 2 ON table 1.field = table 2.field WHERE date < NOW() ORDER BY date DESC";

if ($result = mysql_query($query, $con)) {
  if (mysql_num_rows($result)) {
    while($row = mysql_fetch_array($result)) {

echo "<table id='shows_past'><th>Date/Time</th><th>Venue</th><th>Location</th>";

while($row = mysql_fetch_array($result))
{
echo "an HTML table";
}

echo "</table>";

    }
  } else {
echo "Something went wrong.";
  }
}
else {
    
echo "The query failed.";
}



mysql_close($con);

?>

 

There's a similar question posted here, but I couldn't figure out if we were doing the same thing wrong (very new to MySQL and PHP by the way): http://www.phpfreaks.com/forums/index.php?topic=325757.msg1534001#msg1534001.

 

Thanks a bunch,

 

-Davis

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.