Paging link pages

I have the following script to create links pages in my directory.
It shows all the links in one category on the same page.
I want to break this to show 25 links on one page and the number of pages to show in the bottom. Maximum 20 numbers to show at a time.

db_connect();
$cs=de_code_url($c);
$cs=str_replace("\"","%22",$cs);
$cs=str_replace("’","%27",$cs);
$result=mysql_query(“SELECT * FROM link_data WHERE category=’$cs’ AND status =‘approved’ ORDER BY id DESC”);
while($row=mysql_fetch_array($result))
{
$url=$row[“url”];
$description=$row[“description”];
$title=$row[“title”];
$description=str_replace("%22",""",$description);
$title=str_replace("%22",""",$title);
$description=str_replace("%27","’",$description);
$title=str_replace("%27","’",$title);
print “

$title
$description

”;
}
db_close();

Please anyone help.

Here is an example of pagination:

[php]

<?php function Pages($tbl_name,$limit,$path) { $query = "SELECT COUNT(*) as num FROM $tbl_name"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages[num]; $adjacents = "2"; $page = $_GET['page']; if($page) $start = ($page - 1) * $limit; else $start = 0; $sql = "SELECT id FROM $tbl_name LIMIT $start, $limit"; $result = mysql_query($sql); if ($page == 0) $page = 1; $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $lpm1 = $lastpage - 1; $pagination = ""; if($lastpage > 1) { $pagination .= "
"; if ($page > 1) $pagination.= "« previous"; else $pagination.= "« previous"; if ($lastpage < 7 + ($adjacents * 2)) { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } } elseif($lastpage > 5 + ($adjacents * 2)) { if($page < 1 + ($adjacents * 2)) { for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } $pagination.= "..."; $pagination.= "$lpm1"; $pagination.= "$lastpage"; } elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) { $pagination.= "1"; $pagination.= "2"; $pagination.= "..."; for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } $pagination.= ".."; $pagination.= "$lpm1"; $pagination.= "$lastpage"; } else { $pagination.= "1"; $pagination.= "2"; $pagination.= ".."; for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page) $pagination.= "$counter"; else $pagination.= "$counter"; } } } if ($page < $counter - 1) $pagination.= "next »"; else $pagination.= "next »"; $pagination.= "
\n"; } return $pagination; } //connect to the mysql $db = @mysql_connect('localhost', 'root', '') or die("Could not connect database"); @mysql_select_db('pagination', $db) or die("Could not select database"); ?> Pagination In PHP a { color:#333; text-transform: capitalize; } a:hover{ color: #999; text-decoration:underline } <?php

$page = (int) (!isset($_GET[“page”]) ? 1 : $_GET[“page”]);

$page = ($page == 0 ? 1 : $page);

$perpage = 9;//limit in each page

$startpoint = ($page * $perpage) - $perpage;

$sql = @mysql_query(“select * FROM tutorials order by id desc LIMIT $startpoint,$perpage”);
while($Row = mysql_fetch_array($sql)) {

echo ‘

’.$Row[‘title’].’

’;
}

//show pages

echo Pages(“tutorials”,$perpage,“index.php?”);
?>

Your limit per page is = '<?php echo $perpage;?>'

[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service