views:

41

answers:

1

Trying to pull rows from a table and list them in an ol, however, my code only wants to return the last 2 out of the 3 total rows.

<?php
// Connects to your Database
mysql_connect("mysql.***.com", "***", "***") or die(mysql_error());
mysql_select_db("shpdb") or die(mysql_error());
$data = mysql_query("SELECT * FROM savannah") or die(mysql_error());
$info = mysql_fetch_array( $data );
?>
<h1>Dashboard</h1>
<h3>Manage and view documents.</h3>
<h5>Currently viewing Savannah's list of </h5>
<p><strong>List of patients:</strong></p>
<ol>
<?php
while($info = mysql_fetch_array( $data )) {
// Print out the contents of the entry
Print "<li><b>Name:</b> ".$info['name'] . " <br />";
Print "<b>ID:</b> ".$info['ID']." <br />";
Print "<b>Age:</b> ".$info['age'] ." <br />";
Print "<b>Location:</b> ".$info['location'] ." </li>";
 }
Print "</ol>"; ?>

The table "savannah" contains three rows, but like I said above, running this script only returns the last two. Any ideas? Much appreciated.

+3  A: 

You have

$info = mysql_fetch_array( $data );

used once before actual loop. Just remove the line below mysql_query procedure.

Lukasz Lysik
Thank you. Removed that line and now we're in business.
chris m