Hi
I am quite new to php and mysql, i have built a property website and i am getting stuck with the paging of the results I can get the paging to work fine when i set the variables manually but when the variabes like type and price come from a search form only the 1st page of results works ? I assume this is something simple to sort out but its doing me head in cos ive been stuck on it for months.
The code is below can you please help or even send a link to a tutorial to explain the process
much appreciated
barry
<?php include("connections/connect.php"); ?>
<?php include("inc/top.php"); ?>
<div id="page-container">
<div id="results-main">
<?php
// get all varables from search form
$district = @$_GET;
$type = @$_GET;
$beds = @$_GET;
$condition = @$_GET;
$minprice = @$_GET;
$maxprice = @$_GET;
$pool = @$_GET;
$records_per_page = 5;
// look for starting marker
// if not availble assume 0
(!$_GET) ? $start = 0 : $start = $_GET;
// create query to count records
$query = "SELECT * FROM buysell WHERE type = '$type' ";
$result = mysql_query($query)
or die ( 'error in query' );
// get total number of records
$row = mysql_fetch_row($result);
$total_records = $row[0];
if (($total_records > 0) && ($start < $total_records))
{
// create query to get a batch of records
$query = "SELECT * FROM buysell WHERE type = '$type' LIMIT $start, $records_per_page";
$result = mysql_query($query)
or die ( ' error on paging ' );
while ($row = mysql_fetch_object($result))
{ ?>
<div id="page-container">
<div id="results-main">
<div id="result">
<div id="result-image">
<img src= <?php echo $row->Photo ?> width="180" height="125" border="0" ><img src="images/buttons/viewoff.png" />
</div>
<div id="result-type"> <?php echo $row->Type ?> </div>
<div id="result-price">£<?php echo $row->Price ?></div>
<div id="result-district"> <?php echo $row->District ?> ~ <?php echo $row->Location ?> </div>
<div id="result-general"> <?php echo $row->Bedrooms?> Beds <?php if ( $row->Bedrooms < 1) { echo "studio"; } ;?> </div>
<div id="result-district"> <?php if ( $row > 0 ) { echo "Private Pool"; } ; if ( $row > 0 ) { echo "Communal Pool"; } ; ?> </div>
<div id="result-general">
<?php if ($row == 'yes') {echo "Fitted Kitchen";}; ?>
</div>
</div>
</div>
</div>
<?php }
if ($start >= $records_per_page)
{
echo "<a href=" . $_SERVER .
"?start=" . ($start-$records_per_page) . ">previous
page</a> ";
}
{
echo "<a href=" . $_SERVER .
"?start=" . ($start+$records_per_page) . ">Next Page</a>";
}
}
?>