MySQL results skipping first row
Posted: Thu Aug 20, 2009 5:03 pm
No idea what this is about. If I run the query at the console I get 13 results, but the script only returns 12, starting with number 2.
All help greatly appreciated.
Code: Select all
function getListings($q = 'select * from properties') {
$r = mysql_query($q);
$numRows = mysql_num_rows($r);
$r = mysql_query($q);
$d = mysql_fetch_object($r);
echo "<table><tr>";
$row = 0;
$numRows = mysql_num_rows($r);
while ($d = mysql_fetch_object($r)) {
$row++;
echo "<td><table class=\"result\">";
echo "<tr><td colspan=\"2\" align=\"center\"><a href=\"featured.php?mls=$d->mls\">$d->district</a></td></tr>";
echo "<tr><td><a href=\"featured.php?mls=$d->mls\"><img border=\"0\" src=\"firstpic.php?mls=$d->mls\" height=\"70\" width=\"100\"></a></td>";
echo "<td align=\"left\">";
setlocale(LC_MONETARY, 'en_US'); //this makes money_format() work
echo "<b>Price:</b> ".money_format('%n',$d->asking)."<br />";
echo "<b>Type:</b> ".$d->rtype."<br />";
echo "<b>Beds:</b> ".$d->bed."<br />";
echo "<b>Bath:</b> ".$d->bath."<br />";
echo "</td>";
echo "</tr>";
echo "</table></td>";
if (($row != 0) && !($row % 3)) {
echo "</tr>";
}
}
echo "</table>";
}