Navigation Help
| From: | Nasreen Laghari | Date: | Wed, 04 Jun 2008 15:23:39 +0000 |
| Subject: | Navigation Help | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-45041@lists.php.net to get a copy of this message | ||
Hi,
Could any one please help me with Page Navigation. I have done Next and Previous page Navigation but
confused on printing page numbers (1,2,3,4) and hyperlink them. Below is the code which i'm
halfway on but it only prints "1" with no hyperlink where as I have 11 pages, if i print
$noPages.
Could you please correct where i'm mistaking.
$result = safe_query("select count(*) FROM gig g, venue v WHERE g.gigName LIKE
'%".$gig_name."%' ");
$noEntries = mysql_num_rows($result);
$noPages = ceil($noEntries / $limit);
$currentPage = 0;
if(isset($_GET['pag']) &&
is_numeric($_GET['pag']) &&
$_GET['pag'] > 0 &&
$_GET['pag'] < $noPages){
$currentPage = $_GET['pag'];
}
$start = $currentPage * $pageLimit;
$sqlTotal = "select * FROM gig g, venue v WHERE g.gigName LIKE
'%".$gig_name."%' ".$start.",".$limit;
for($a = 0; $a < $noPages; $a++){
if($currentPage == $a){
echo($a+1);
}else{
echo '<a
href="'.$_SERVER['PHP_SELF'].'?spag='.$a.'">'.($a+1).'</a>';
}
if($a < $noPages - 1){
echo '-';
}
}