Jump to content


Photo

First row of data is not showing up


  • Please log in to reply
2 replies to this topic

#1 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 05 September 2006 - 08:36 PM

On this page: http://www.highlandb...m/phase-two.php the first item in the list of lots should be Lot #2. Instead it's showing Lot#3 as the first item. When I view the database in PHPMyAdmin it clearly shows lot #2 as the first row. I can't understand why it doesn't show in the posted results in the page. Here's the code:

$sql=("SELECT * FROM phase_two");
$results=mysql_query($sql);
$row = mysql_fetch_row($results);
$num_rows = mysql_num_rows($results);
if ($num_rows == 0) {
echo "<font class='bodytext'><center>We are sorry. The lot information is unavailable at this time.<br /> Please contact us for details on available lots.<br />";
} else {

echo "
		<table width='700' border='0' align='center' onMouseover=\"changeto(event, 'darkkhaki')\" onMouseout=\"changeback(event, 'lightgoldenrodyellow')\">
			<tr>
				<th><font face=\"Verdana\" size=\"2\">Lot #</th>
				<th><font face=\"Verdana\" size=\"2\">Sq. Ft.</th>
				<th><font face=\"Verdana\" size=\"2\">Street</th>
				<th><font face=\"Verdana\" size=\"2\">Frontage</th>
				<th><font face=\"Verdana\" size=\"2\">Location</th>
				<th><font face=\"Verdana\" size=\"2\">View</th>
				<th><font face=\"Verdana\" size=\"2\">Acres</th>
				<th><font face=\"Verdana\" size=\"2\">Price</font></th>
				<th><font face=\"Verdana\" size=\"2\">&nbsp;</th>
			</tr>";
	while ($a_row = mysql_fetch_array( $results )) {
		echo "
			<tr bgcolor=\"lightgoldenrodyellow\">
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">" . $a_row['lot'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">" . $a_row['sq_feet'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">" . $a_row['street'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">" . $a_row['frontage'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">" . $a_row['location'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">" . $a_row['view'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">" . $a_row['acres'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\">\$" . $a_row['sale_price'] . "</td>
				<td style=\"text-align: center;\"><font face=\"Verdana\" size=\"1\"><a href=\"contact-p2.php?id=" . $a_row['lot'] . "\">Contact</a></td>
			</tr>";
	}

print "</table>\n";
echo "<br>"; 
}
//print "</table>\n";


I can't see anything here that would tell it to ignore row 1 of the table. Ideas?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 05 September 2006 - 09:01 PM

$sql=("SELECT * FROM phase_two");
$results=mysql_query($sql);
$row = mysql_fetch_row($results);

That line reads first row and throws it away

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 05 September 2006 - 09:16 PM

Thanks, Barand. That speck of code wasn't even necessary since the $row variable wasn't being used. I commented it out and the script is now producing the display of all the data rows.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users