Good day everyone from beautiful California,
I have been able to limit the number of listings showing per page ($per_page=10)
But how do I limit the number of pages so I do not have rows after rows of pages.
The way it looks now:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 >>
The way it should look:
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 >>
The code:
$option_page=$_REQUEST[option_page];
$per_page = 10;
$sqlsearch="select a.*,b.session_id from fsbo_listing a, searchresults b where a.listingid=b.listingid and b.session_id=\"$sessionid\" order by b.searchid";
//echo"<br>Final Query-->".$sqlsearch;
if (!isset($option_page)) {
$option_page = 1;
}
$prev_option_page = $option_page - 1;
$next_option_page = $option_page + 1;
$option_query = mysql_query($sqlsearch);
$option_page_start = ($per_page * $option_page) - $per_page;
$num_rows = mysql_num_rows($option_query);
if ($num_rows <= $per_page) {
$num_pages = 1;
} else if (($num_rows % $per_page) == 0) {
$num_pages = (int)($num_rows / $per_page);
} else {
$num_pages = (int)($num_rows / $per_page) + 1;
}
$sqlsearch = $sqlsearch . " LIMIT $option_page_start, $per_page";
THANK YOU A MILLION TIMES.
Natasha;)