Sorry for such a simple question, but I am a beginner and catch on to some stuff fast...and others not so fast.
I am trying to build a simple pagination. I have spend two days on it. At this stage, I have the next and previous buttons working, but no results of my query are displayed. Can someone take a peek at my code and let me know what I am doing wrong? I would be very appreciative.
<?
if(!isset($start)) $start = 0;
$username="xxx";
$password="xxx";
$database="xxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * ,IF (lister_office_name like 'Century 21', 1, 0)
AS featured
FROM residential
WHERE town like '%$selecttown'
AND list_price like '%$selectprice'
AND bedrooms like '%$bedroomsel'
AND baths like '%$bathselect'
ORDER BY featured
DESC LIMIT " . $start . ", 10";
$result=mysql_query($query) or die (mysql_error());
$num=mysql_numrows($result);
?>
<?
$query = "SELECT count(*) as count FROM residential WHERE town like '%$selecttown' AND list_price like '%$selectprice' AND bedrooms like '%$bedroomsel' AND baths like '%$bathselect'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 10) .
"\">Previous</a><BR>\n";
if($numrows > ($start + 10))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 10) .
"\">Next</a><BR>\n";
?>
<?
if(mysql_numrows($result) == '0') {
echo "Sorry, no results were found...";
} else {
// display results here
}
?>
<?
while ($row = mysql_fetch_array($result)) // this will grab the results from query
{
?>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="12%" bgcolor="#F3F3E0">
<img src="getthumb.php?thumb=<? echo $row['Id']; ?>">
</td>
<td width="12%" align="center" bgcolor="#F3F3E0"><a href="test2.php?Id=<? echo $row['Id']; ?>"><b><? echo $row['Id']; ?></b></a>
</td>
<td width="12%" align="center" bgcolor="#F3F3E0"><? echo $row['town']; ?></td>
<td width="12%" align="center" bgcolor="#F3F3E0"><? echo $row['rooms']; ?></td>
<td width="13%" align="center" bgcolor="#F3F3E0"><? echo $row['bedrooms']; ?></td>
<td width="13%" align="center" bgcolor="#F3F3E0"><? echo $row['baths']; ?></td>
<td width="13%" align="center" bgcolor="#F3F3E0"><? echo $row['list_price']; ?></td>
<td width="13%" align="center" bgcolor="#F3F3E0">
<a href="test2.php?Id=<? echo $row['Id']; ?>">Click to view more</a>
</td>
</tr>
</table>
<?
}
?>