include_once('config.inc.php');
$id = $_REQUEST['id'];
$_SESSION['ref_id'] = $id;
$sub_cats_rs = mysqli_query($dbcon,"select * from sub_cats where sub_cat_id='$id'") or die(mysqli_error());
$sub_cats = mysqli_fetch_array($sub_cats_rs);
$cur_sub_cat_id = $sub_cats['main_cat_id'];
$cur_sub_cat_caption = $sub_cats['caption'];
$subcat_rs = mysqli_query($dbcon,"select * from sub_cats where main_cat_id = '$cur_sub_cat_id' ORDER BY sorting_order") or die(mysqli_error());
$cur_main_cat_rs = mysqli_query($dbcon,"select * from main_cat where main_cat_id='$cur_sub_cat_id'");
$cur_main_cats = mysqli_fetch_array($cur_main_cat_rs);
$cur_main_id=$cur_main_cats['main_cat_id'];
$banner = mysqli_query($dbcon,"select * from main_banner where mcat_id='$cur_main_id'")or die(mysqli_error());
?>
//-----------------------------------------------
//PAGING STARTS FROM HERE
//-----------------------------------------------
// how many rows to show per page
$rowsPerPage = PRODUCTS_PER_PAGE;
$productsPerRow = PRODUCTS_PER_ROW;
// by default we show first page
$pageNum = 1;
// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}
// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;
// how many rows we have in database
$prdrs=mysqli_query($dbcon,"Select * from products where sub_cat_id='$id'");
$numrows=mysqli_num_rows($prdrs);
$total_prds=$numrows;
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
if($maxPage==0) {
$maxPage=1;
}else{
$maxPage=$maxPage;
}
$self = $_SERVER['PHP_SELF']."?id=$id";
$prdrs=mysqli_query($dbcon,"Select * from products where sub_cat_id='$id' ORDER BY sorting_order LIMIT $offset, $rowsPerPage");
?>
$rs=mysqli_query($dbcon,"select * from main_cat ORDER BY sorting_order");
while($rows=mysqli_fetch_array($rs)){
$curmcat=$rows['main_cat_id'];
$rs1=mysqli_query($dbcon,"Select * from sub_cats where main_cat_id = '$curmcat' order by sorting_order");
?>