I'm working with PHP/MySQL to create a search box for a website. The problem I'm having is that when the results are more than the maximum allowed per page (2), it displays the "next 2" button after every result like below. How do I make it so that it only appears once at the bottom of all the results for the given page?
orange you glad you picked this?
a movie a day keeps the doctor away
a movie a day keeps the docto...
Next 2
test
hello there, doctor. hello nice to see you
hats hats dogs dogs
Next 2
Here is the code at the end of my search code that I think is the culprit:
<hr>
<?php
} //end foreach $trimmed_array
if($row_num_links_main > $limit){
// next we need to do the links to other search result pages
if ($s>=1) { // do not display previous link if 's' is '0'
$prevs=($s-$limit);
echo "<div align='left'><a href='$PHP_SELF?s=$prevs&q=$var&catid=$catid'>Previous " .$limit. "</a></div>";
}
// check to see if last page
$slimit =$s+$limit;
if (!($slimit >= $row_num_links_main) && $row_num_links_main!=1) {
// not last page so display next link
$n=$s+$limit;
echo "<div align='right'><a href='$PHP_SELF?s=$n&q=$var&catid=$catid'>Next " .$limit. "</a></div>";
}
}
} //end foreach $newarr
?>