session_start();
include("a-classes/paging.php");
$conn = mysql_connect("67.59.187.233","clubricr_admin","cld5879");
@mysql_select_db("clubricr_db");
$gcat = $_GET['cat'];
if ($gcat == '') { $_SESSION['cat'] = '1'; } else { $_SESSION['cat'] = $gcat; }
$cat = $_SESSION['cat'];
$paging = new Paging($conn ,"ID","asc",$_REQUEST['page']);
$paging->set_total("select count(*) from PHOTOS where STATUSS = 'active' and CAT ='$cat'");
$result = $paging->get_results("select * from PHOTOS where STATUSS = 'active' and CAT ='$cat'");
/**********************************PAGE***************************/
$count_query = "select count(*) from PHOTOS where STATUSS = 'active' and CAT ='$cat'";
$result222 = mysql_query($count_query) or die($count_query);
//echo $count_query."
";
$myrowaaa = mysql_fetch_array($result222);
$total = $myrowaaa[0];
if ($total == '') { $total == "null";}
if($_POST['layout'] == 1)
$_SESSION['layout'] = 1;
if($_POST['layout'] == 2)
$_SESSION['layout'] = 2;
if(!$_SESSION['layout'])
$_SESSION['layout'] = 1;
if(($_SESSION['layout'] == 2))
$scale=15;
else
$scale=15;
$page = $_REQUEST['page'] ;
if ($page == ''){
$page=1;
}
if($page != 'all')
{
$cpage = intval($page);
$totalpage = intval($total/$scale);
if ($totalpage*$scale != $total)
$totalpage = $totalpage + 1;
if ($cpage ==1) {
$cline = 0 ;
} else {
$cline = ($cpage*$scale) - $scale ;
}
$limit=$cline+$scale;
if ($limit >= $total)
$limit=$total;
$scale1 = $limit - $cline;
$limit_portion = "LIMIT $cline,$scale1 ";
} else
{
$totalpage = ceil($total/$scale);
$limit_portion = "";
}
$limit_portion = " ORDER BY ASC, ".(!$sortby ? "RAND()" : $sortby." ".$sortorder)." ".$limit_portion;
/***************************************************************/
?>