<?php

/* FIRESHOP: Advanced Content Market System                         */

/* ============================================                         */

/*                                                                      */

/* Copyright (c) 2012 by Mohamad Porhaji                                */

/* http://Firedesign.ir                                                   */

/*                                                                      */

/* This program is free software.  */

/************************************************************************/

/* $Id: category.php,v 1.0.0.1 2012/02/18 By Mohamad Porhaji $ */
@session_start();
define('CAT_FILE', true);
require_once("mainfile.php");
global $db;


if(!isset($_GET['id']) or !is_numeric(@$_GET['id']))
{
$error="چنين دسته اي در سايت وجود ندارد";

}else{

global $db;
counter_face();
$id_cat =$_GET['id'];
$_SESSION['CAT_ID'] = $id_cat;
$query = $db->sql_query("SELECT * FROM `fireshop_category` WHERE id='$id_cat'") or die(mysql_error());
if($db->sql_numrows($query) == 0 ){
$error="چنين دسته اي در سايت وجود ندارد";
}else{

$row = $db->sql_fetchrow($query);
$title = $row['title'];

$error="";
}
}

$title_page_over="دسته ي $title";
$page_title = "دسته ي $title ";


function pagination_cat(){
echo "<link href=\"template/pagination.css\" rel=\"stylesheet\" type=\"text/css\" >\n";
if (defined('CAT_FILE'))
{  global $db,$pro_limit,$id_cat;

$total_pro = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `product_cat`='$id_cat' "));
$page_num=ceil($total_pro/$pro_limit);
if($page_num>0){
echo"<br/><table dir=\"rtl\" width=\"690\">
<tr align=\"center\">
<td >
<div class=\"pagination\">
<div class=\"this_page\"><a>1</a></div>";
for($i = 2;$i<=$page_num;$i++){
if($i<=8){
echo"<div class=\"page_nav\"><a href=\"page_cat.php?id=$i\">$i</a></div>";}
}echo"<div class=\"page_t\"><a>تعداد كل صفحات : $page_num</a></div><div class=\"clear\"></div></div></td></tr></table>";}
}else{

$total_pro = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `product_cat`='$id_cat' "));
$page_num=ceil($total_pro/$pro_limit);
if($page_num>0){
echo"<br/><table dir=\"rtl\" width=\"690\">
<tr align=\"center\">
<td >
<div class=\"pagination\">
<div class=\"this_page\"><a>$last_id_page</a></div>";
for($i = $page_id;$i<=$page_num;$i++){
if($i<=8){echo"<div class=\"page_nav\"><a href=\"page_cat.php?id=$i\">$i</a></div>";}
}echo"<div class=\"page_t\"><a>تعداد كل صفحات : $page_num</a></div><div class=\"clear\"></div></div></td></tr></table>";}
}


}


function content()

{
global $db,$id_cat,$error;
if(!isset($_GET['id']) or !is_numeric(@$_GET['id']))
{
echo"چنين دسته اي در سايت وجود ندارد";

}else{

global $db,$id_cat,$error;
$id_cat =$_GET['id'];
$query = $db->sql_query("SELECT * FROM `fireshop_category` WHERE id='$id_cat'") or die(mysql_error());
if($db->sql_numrows($query) == 0 ){
echo"چنين دسته اي در سايت وجود ندارد";
}else{
$total_pro = $db->sql_numrows($db->sql_query("SELECT * FROM fireshop_product WHERE `product_cat`='$id_cat' "));
if($total_pro<1){echo"محصولي در اين دسته وجود ندارد";}
$row = $db->sql_fetchrow($query);
$title = $row['title'];
}
}
}


theme();

?>