ok, so i have tried everything here
searched the forum, found codes that didnt work, or werent what i wanted, and looked on google for it
but i cant find a pagination script that changes when on say page 10
so instead of showing << PREV 1 2 3 4 5 6 7 8 9 10 NEXT >>
it would show << PREV 6 7 8 9 10 11 12 13 14 15 NEXT >>
heres my current script
<?
$search = $_GET[string];
$page = $_GET[page];
// limit value for number of records to be shown per page
// query database to find total number of records to display
$limit = 10;
$query_count = "select * from waypoints where name like '%$search%'";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page))
$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "select * from waypoints where name like '%$search%' order by name ASC LIMIT $limitvalue, $limit ";
$result = mysql_query($query) or die("Error: " . mysql_error());
$count_result = mysql_num_rows($result);
// Display links at the top to indicate current page and number of pages displayed
$numofpages = ceil($totalrows / $limit);
echo"<br><p><b>$totalrows</b> result(s) for: \"$search\"</p>";
$from=$limit*$page-$limit+1;
$to=$from + $count_result-1;
while ($row = mysql_fetch_array($result)) {
// SHOW RESULTS FOR WAYPOINTS
$name = $row[name];
$string = $search;
// <span style=\"background-color: #FFFF00\"></span>
$name = str_replace($string, " <span style=\"background-color: #FFFFFF\">$string</span> ", $name);
$string = ucfirst($search);
$name = str_replace($string, " <span style=\"background-color: #FFFFFF\">$string</span> ", $name);
echo ("<b>");
echo "<a href=waypoints/download.php?id=".$row[id]."";
echo (">".$name."</a> (".$row[dl].")</b><br>");
// END SHOW RESULTS FOR WAYPOINTS
}
// start 123 next>> table
echo "<br><table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"left\">";if($numofpages>1){echo"Showing: $from - $to</td></tr><tr><td> </td></tr><tr><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"center\">";}
// display previous link if page is not 1
if($page != 1){
$pageprev = $page - 1;
echo("<a href=$PHP_SELF?page=$pageprev&string=$search&go=$_GET[go]><< PREV</a> ");
}
// display page nos if not 1
for($i = 1; $i <= $numofpages; $i++){
if($numofpages>1){
if($i == $page)
echo(" ".$i." ");
else
echo(" <a href=$PHP_SELF?page=$i&string=$search&go=$_GET[go]>$i</a> ");
}}
// display next page link if there is more than one
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
echo("<a href=$PHP_SELF?page=$pagenext&string=$search&go=$_GET[go]>NEXT >></a>");
}
// end 123 next>> table
echo"</td></tr></table><br>";
?>
any suggestions on how i could achieve this?!
thanks peeps 😉