<?php
include("config.php");
   class Datas {
      
		var $prd_post = array();
		var $photo = array();
		var $tablename;
		var $data_id;
		var $fields;
	    var $vals;
		var $field_id;
		var $event_id;
		var $update_id;
		var $add_date;
		var $upd_date;
		var $event_content;
		var $event_name;
		var $event_status;
		var $temp_desc;
		var $event_day;
		var $event_mon;
		var $event_year;
		var $event_stat;
		var $rlimit;
		var $qry;
		var $obj;
		var $obj_dat;
		var $evt_content;
		var $title;
		var $stat;
		var $msg;
		var $event_category;
		var $category;
		var $blk;
		var $topic_search;
		var $topic_category;
		var $conditions;
		var $order; 
		var $start;
		var $items;
		var $sel_field;
		var $sel_obj;
		var $sql;
		var $sel_qry;
		var $ord;
		var $img;
		var $name;
		var $description;
		var $id;
		var $cat;
		var $status_field;
		var $db_stat;
		var $stat_id;
		var $field_stat;
		var $stat_qry;
		var $value='';
		var $fn;
		var $passurlvalue;
		var $table_nam;
		
#-----------------------------------------------------	
	function display_active()
		{
			
				$sql="select ".$this->img.",".$this->name.",".$this->category.",".$this->id." from ".$this->table_nam."  where  ".$this->category."='".$this->cat."' and  ".$this->status_field."=1  order by ".$this->id." desc limit 0,12";
				$trs=mysql_query($sql);
				
				//echo $sql;
				//exit;
				return $trs;
		}	
		
		
		function getData_orgcat()
		{
			$sql="select * from  ".$this->tablename.$this->condition;
			$rs = mysql_query($sql);
			return $rs;

		}
		
		 function getData_orgdat()
		{
			
			
		$sql="select * from  ".$this->tablename.$this->condition;
			$rs = mysql_query($sql);
			return $rs;

		}
		function display_active_frame_new()
		{
			
				$sql="select ".$this->img.",".$this->name.",".$this->category.",".$this->id." from ".$this->table_nam."  where  ".$this->category."='".$this->cat."' and  ".$this->status_field."=1  order by ".$this->id." desc limit 0,9";
				$trs=mysql_query($sql);
				
				//echo $sql;
				//exit;
				return $trs;
		}	
		function display_active_facs()
		{
			
				$sql="select ".$this->img.",".$this->name.",".$this->category.",".$this->id." from ".$this->table_nam."  where  ".$this->category."='".$this->cat."' and  ".$this->status_field."=1  order by ".$this->id." desc limit 0,9";
				$trs=mysql_query($sql);
				
				//echo $sql;
				//exit;
				return $trs;
		}	
		function display_active_desc()
		{
			
				$sql="select ".$this->img.",".$this->name.",".$this->description.",".$this->category.",".$this->id." from ".$this->table_nam."  where  ".$this->category."='".$this->cat."' and  ".$this->status_field."=1  order by ".$this->id." desc limit 0,12";
				$trs=mysql_query($sql);
				
				//echo $sql;
				//exit;
				return $trs;
		}	
		function display_active_desc_evt()
		{
			
				$sql="select ".$this->img.",".$this->name.",".$this->description.",".$this->category.",".$this->id." from ".$this->table_nam."  where  ".$this->category."='".$this->cat."' and  ".$this->status_field."=1  order by ".$this->id." desc limit 0,6";
				$trs=mysql_query($sql);
				
				//echo $sql;
				//exit;
				return $trs;
		}	
		
		function display_activenw()
		{
			
				$sql="select ".$this->img.",".$this->name.",".$this->id.",".$this->description." from ".$this->table_nam."  where   ".$this->status_field."=1  order by ".$this->id." desc limit ".$this->start.",".$this->items;
				
				//echo $sql;
				//exit; 
				
				
				$trs=mysql_query($sql);
				return $trs;
		}	
	function gettabcount($table)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename;
		//echo $sql; exit;
		$result = mysql_query($sql);			
		$this->rowCount = mysql_num_rows($result);	
		return $this->rowCount;
		//exit;
	}
	
	function saveDatacomment($table,$fields,$vals)
	{
		 
		 
		 $this->tablename=$table;
		 $this->fields=$fields;
		 $this->vals=$vals;
		 $sql= "insert into ".$this->tablename."(".$fields.") values(".$vals.")";
		
		//print $sql;exit;
		mysql_query($sql)or die(mysql_error());
		$this->data_id = mysql_insert_id();
	}
	
	
	
	
	function getvalues($table)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename;
		//echo $sql; exit;
		$result = mysql_query($sql);	
				
		
		return $result;
		//exit;
	}
	function getvalues_nam($table,$type)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." where type='".$type."'";
		//echo $sql; exit;
		$result = mysql_query($sql);	
				
		
		return $result;
		//exit;
	}
	function getvalues_namval($table,$field,$name)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." where ".$field." like '".$name."'";
		//echo $sql; exit;
		$result = mysql_query($sql);	
				
		
		return $result;
		//exit;
	}
	function getvalues_selcat($table,$field,$name)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." where ".$field."='".$name."'";
		//echo $sql; exit;
		$result = mysql_query($sql);	
				
		
		return $result;
		//exit;
	}
	function getvalues_selnews($table,$field,$name,$status_field)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." where ".$field."='".$name."' and ".$status_field."=1";
		//echo $sql; exit;
		$result = mysql_query($sql);	
				
		
		return $result;
		//exit;
	}
	function getvalues_disp($table,$type)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." where type!='".$type."'";
		//echo $sql; exit;
		$result = mysql_query($sql);	
				
		
		return $result;
		//exit;
	}
	function getvalues_disp_type($table,$type)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." where type='".$type."'";
		//echo $sql; exit;
		$result = mysql_query($sql);	
				
		
		return $result;
		//exit;
	}
	function getvalues_latest($table,$field)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." order by  ".$field." desc  limit 0,1";
		//echo $sql; exit;
		$result = mysql_query($sql);	
		if($result){
		$obj = mysql_fetch_object($result);	
		}else{
		$obj =0;
		}		
		
		return $obj;
		//exit;
	}
	function getvalues_latest_newssec($table,$field,$news_num)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." order by  ".$field." desc  limit 0,".$news_num;
		//echo $sql; exit;
		$result = mysql_query($sql);	
		$obj = mysql_fetch_object($result);			
		
		return $obj;
		//exit;
	}
	function getvalues_latest_index($table,$field,$status_field)
	{	
		$this->tablename=$table;
		$sql = "select * from ".$this->tablename." where ".$status_field."=1 order by  ".$field." desc  limit 0,1";
		//echo $sql; exit;
		$result = mysql_query($sql);
		if($result){	
		$obj = mysql_fetch_object($result);			
		
		return $obj;
		}
		//exit;
	}
	function gettabcount_condition($table,$conditions)
	{	
		        $this->conditions=$conditions;
			    $this->tablename=$table;
				
				$sql="select * from ".$this->tablename.$conditions;
				$trs=mysql_query($sql);
				$this->totalrows = mysql_num_rows($trs);
				return($this->totalrows);
	}
	
function getdata_s_condition()
	{	
		      
				
				$sql="select * from ".$this->tablename.$this->conditions;
				$trs=mysql_query($sql);
				return($trs);
	}
	
	
	  
		
		function getData($table,$id,$field_id)
		{
			$this->field_id=$field_id;
		    $this->data_id=$id;
			$this->tablename=$table;
			$sql="select * from  ".$this->tablename." where ".$this->field_id."='".$this->data_id."'";
			//echo $sql;
			$rs = mysql_query($sql);
			$obj=mysql_fetch_object($rs);
			$this->obj=$obj;
			return $this->obj;

		}

		function getData_latest($table,$id,$field_id,$field,$sel_field)
		{
			$this->field_id=$field_id;
		    $this->data_id=$id;
			$this->tablename=$table;
			
			$sql="select ".$sel_field.",".$field_id." from  ".$this->tablename." where ".$this->field_id."='".$this->data_id."' order by  ".$field." desc  limit 0,1";
			//echo $sql;
			$rs = mysql_query($sql);
			$obj=mysql_fetch_object($rs);
			$this->obj=$obj;
			return $this->obj;

		}


		function getRowcount()
		{	
			$sql = "select * from kerz_events where event_id='{$this->event_id}' and event_status='1' order by event_id desc";
			$result = mysql_query($sql);			
			$this->rowCount = mysql_num_rows($result);	
		}
		
		
		function getDataListings($table,$status,$order,$start,$items)
		{
			
				$sql="select * from ".$table." order by ".$order." desc limit ".$start.",".$items;
				$trs=mysql_query($sql);
				$this->totalrows = mysql_num_rows($trs);
				$limit="";
				if($this->rlimit>0)
				{
				$limit=" limit $this->start,$this->rlimit";
				}
				$sql .= $limit;
				//echo $sql;
				$rs=mysql_query($sql);
				return $rs;
		}
		
	function getDataListings_active($table,$status,$order,$start,$items)
		{
			
				$sql="select * from ".$table." where  ".$status." = 1 order by ".$order." desc limit ".$start.",".$items;
				$trs=mysql_query($sql);
				$this->totalrows = mysql_num_rows($trs);
				$limit="";
				if($this->rlimit>0)
				{
				$limit=" limit $this->start,$this->rlimit";
				}
				$sql .= $limit;
				//echo $sql;
				$rs=mysql_query($sql);
				return $rs;
		}	
		
		function getDataListings_condition($table,$status,$order,$start,$items,$conditions)
		{
				$this->order=$order;
		        $this->conditions=$conditions;
			    $this->tablename=$table;
				$this->start=$start;
				$this->items=$items;
				$sql="select * from ".$this->tablename.$conditions.$order." limit ".$this->start.",".$this->items;
				$trs=mysql_query($sql);
				$this->totalrows = mysql_num_rows($trs);
				$limit="";
				if($this->rlimit>0)
				{
				$limit=" limit $this->start,$this->rlimit";
				}
				$sql .= $limit;
				//echo $sql;
				$rs=mysql_query($sql);
				return $rs;
		}
		function select_query($table,$fields){
		
			    $this->tablename=$table;
				$this->fields=$fields;
				$sql="select distinct(".$this->fields.") from ".$this->tablename;
				$trs=mysql_query($sql);
				return $trs;
		}
		function galdisplay_active($id)
		{
			
				 $sql="select gallery_id,gallery_item,gallery_name  from kerz_gallery   where  gallery_status = 1 and gallery_item=".$id." order by gallery_id desc limit 0,9";
				$trs=mysql_query($sql);
				return $trs;
		}
		function galdisplay_active_more($id)
		{
			
				 $sql="select gallery_id,gallery_item,gallery_name  from kerz_gallery   where  gallery_status = 1 and gallery_item=".$id." order by gallery_id desc limit 0,6";
				$trs=mysql_query($sql);
				return $trs;
		}
		function alphabetic_gal($val){
		//$sel_sql=mysql_query("select gallery_id from 
		$gal_sql=mysql_query("SELECT * FROM kerz_gallery where gallery_status = ".$val." and gallery_name like 'A%' or gallery_name like 'a%'");
		}	
			function display_active_com($item)
		{
			
				$sql="select ".$this->img.",".$this->name.",".$this->category.",".$this->id." from ".$this->table_nam."  where   ".$this->status_field."=1  order by ".$this->id." desc limit ".$this->start.",".$this->items;
				$trs=mysql_query($sql);
				return $trs;
		}
		function display_default($val){
		//$sel_sql=mysql_query("select gallery_id from 
		$gal_sql=mysql_query("SELECT * FROM kerz_gallery where gallery_status = ".$val." and gallery_name like 'A%' or gallery_name like 'a%'");
		}	
		function select_qry()
		{
				
				$sql="select * from ".$this->tablename.$this->conditions.$this->order." limit ".$this->start.",".$this->items;
				$trs=mysql_query($sql);
				$rs=mysql_query($sql);
				return $rs;
		}	
		function select_imgqry()
		{
				
				$sql="select * from ".$this->tablename.$this->conditions;
				$trs=mysql_query($sql);
				$rs=mysql_query($sql);
				return $rs;
		}	
   }
   function saveDatacomment($table,$fields,$vals)
	{
		 
		 
		
		 $sql= "insert into ".$table."(".$fields.") values(".$vals.")";
		
		//print $sql;exit;
		mysql_query($sql)or die(mysql_error());
	}
	
	
	 
?>