hi i have made a simple pagination but it is creating problem , the problem is that if there are any products under the category that is clicked in the left menu then the page works fine but if it does not have any product listed under that category then the page halts no eror is diplayed and the page halts at the line
the working example can be seen here link
here is the full code for that pagination each time the page loads it checks if the variable $bingo is poted or not which contains a cat_id and against that category id it fetches the results and makes the pages
[code=php]
class Pager{
function getPagerData($n umHits, $limit, $page){
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
if(!empty($_GET['bingo'])){$cat_id=$_GE T['bingo'];}else{$cat_id= '24';}
if(!empty($_REQ UEST['page'])){$page = $_REQUEST['page'];}else{$page=1; }
$limit=6;
$result = mysql_query("SE LECT count(*) FROM ".PRODUCT." p,".PRODUCT_DES CRIPTION." pd,".PRODUCT_TO _CATEGORY." ptc WHERE p.prod_id=pd.pr od_id AND ptc.cat_id='$ca t_id' AND ptc.prod_id=p.p rod_id");
$total = mysql_result($r esult, 0, 0) or die(mysql_error ());
$pager = Pager::getPager Data($total, $limit, $page);
$offset= $pager->offset;
$limit= $pager->limit;
$page= $pager->page;
$error="";
[/code]
Code:
$total = mysql_result($result, 0, 0) or die(mysql_error());
here is the full code for that pagination each time the page loads it checks if the variable $bingo is poted or not which contains a cat_id and against that category id it fetches the results and makes the pages
[code=php]
class Pager{
function getPagerData($n umHits, $limit, $page){
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
if(!empty($_GET['bingo'])){$cat_id=$_GE T['bingo'];}else{$cat_id= '24';}
if(!empty($_REQ UEST['page'])){$page = $_REQUEST['page'];}else{$page=1; }
$limit=6;
$result = mysql_query("SE LECT count(*) FROM ".PRODUCT." p,".PRODUCT_DES CRIPTION." pd,".PRODUCT_TO _CATEGORY." ptc WHERE p.prod_id=pd.pr od_id AND ptc.cat_id='$ca t_id' AND ptc.prod_id=p.p rod_id");
$total = mysql_result($r esult, 0, 0) or die(mysql_error ());
$pager = Pager::getPager Data($total, $limit, $page);
$offset= $pager->offset;
$limit= $pager->limit;
$page= $pager->page;
$error="";
[/code]
Comment