I am having problem in restricting search result page number in php page.
I am using 3 fields to select user input and displaying search results at the bottom . Whenever I select all fields, the page number goes on increasing at the bottom which equals to total number of pages in DB and hence stretches the page wide and hence changes the page layout.
What if I only want like 10 or 15 pages to display and rest of them to be shown by next-> which i m currently using for changing from page 1 to page 2. Image below 34 result which are total number of entries and I want only 15.
I am using following code:
$Nav="";
If($page > 1) {
$Nav .= "<A HREF=\"search.php?page=".
($page-1)."&countryCode=".
urlencode($country)."&linkageType=".
urlencode($linkage)."&college=".
urlencode($college) . "\"><< Prev</A>";
}
For($i = 1 ; $i <= $NumberOfPages ; $i++) {
If($i == $page) {
$Nav .= " <B>$i</B>";
}Else{
$Nav .= " <A HREF=\"search.php?page=".
$i."&countryCode=" .urlencode($country).
"&linkageType=".urlencode($linkage).
"&college=".urlencode($college)."\">$i</A>";
}
}
If($page < $NumberOfPages) {
$Nav .= " <A HREF=\"search.php?page=".
($page+1)."&countryCode=".urlencode($country).
"&linkageType=".urlencode($linkage)."&college=".
urlencode($college) . "\"> Next>></A>";
}
Echo "<BR><BR>" . $Nav;
echo "</center>";
what I am looking for is just Search results restricting to 15 pages instead some extra pages followed by next button tab.
$maxPages=15; //set up our max value
for($x=1;$x<=$numOfPages;$x++){ //make a loop of all avail pages
if($x==$maxPages){
echo" Next "; //if we have reaced our max number, show a next link
$x=$numOfPages+1; // and increment our loop counter PAST our max loopable value
}else{
echo" $x ";
}
}
not pretty, and not very well designed, but does work, and is at a beginner level for understanding..