Hi,
I'm trying to have data displayed at 25 rows/page. the first page outputs the data correctly and counts the total amount of rows found. when the "next" link is clicked on [page 2], no rows are found. not sure what it is, i may be over complicating it.
here's the code:
$where_clause = "where area = '$area_search' && Specialty = '$type'";
$strSQL = "SELECT * FROM tnh2 $where_clause";
$pagelimit = "25";
$result = mysql_query($strSQL) or die ("Error in search string. ");
$totalrows = mysql_num_rows($result);
$pagenums = ceil($totalrows/$pagelimit);
// get the starting page
if ($page=='')
{
$page='1';
}
echo "<br>Page $page > ";
// get the starting row value
$start = ($page - 1) * $pagelimit;
$starting_no = $start + 1;
// get end count for this page
echo " $totalrows "."matches found > ";
if ($totalrows - $start < $pagelimit)
{
$end_count = $totalrows;
}
elseif ($totalrows - $start >= $pagelimit)
{
$end_count = $start + $pagelimit;
}
echo " Results $starting_no to $end_count shown.<br><br>";
// create dynamic next and previous page links
If ($totalrows - $end_count > $pagelimit)
{
$var2 = $pagelimit;
}
elseif ($totalrows - $end_count <= $pagelimit)
{
$var2 = $totalsrows - $end_count;
}
// previous link
if ($page > 1)
{
echo "<a href=\"".$PHP_SELF."?page=".($page - 1)."&area=".$area_search."&Specialty=".$type."\">
Previous 25 Listings</a>    ";
}
// next link
if ($page < $pagenums)
{
echo "<a href=\"".$PHP_SELF."?page=".($page + 1)."&area=".$area_search."&Specialty=".$type."\">Next 25 Listings</a>";
}
$strSQL = "SELECT * FROM tnh2 $where_clause Limit $start, $pagelimit";
$result = mysql_query($strSQL) or die ("Error in strSQL: $strSQL. " . mysql_error());
?>
<?
// if records present
if (mysql_num_rows($result) > 0)
{
// iterate through resultset
// print listings
while($row2 = mysql_fetch_object($result))
{
?>
the data is then printed after this.....
thanks for any help.