System: Windows NT WINDOWS18 10.0 build 17763 (Windows Server 2016) AMD64 | User: IWPD_3544(appclien)

Path: D:\Inetpub\vhosts\appclients.in\fruits-vegitables.nmvm.org\includes

[Back to List]
<?php
include "admin/config.php";
class admin_main{

function select_all($table,$o){
global $con;
$this->table_name=$table;
$select_query=mysqli_query($con,"SELECT * FROM ".$this->table_name." $o ") or die(mysqli_error($con));
return $select_query;
}

function insert_review_dtl($table){
global $con;
$this->table_name=$table;
$review_is= addslashes($_POST['review_is']);
$pid= addslashes($_REQUEST['pid']);
$entrydate= strtotime(date("d/m/Y"));
$insert_query=mysqli_query($con,"insert into ".$this->table_name." set name='$_POST[name]',review_is='$review_is',rating='$_POST[rating]',entrydate='$entrydate',pid='$pid'") or die(mysqli_error());
  if($insert_query){
  return "success";
  }else{
  return "fail";
  }
}


}//closing of class
	function get_product_name($pid){
	global $con;
		$result=mysqli_query($con,"select name from product where id=$pid") or die("select name from product where id=$pid"."<br/><br/>".mysqli_error());
		$row=mysqli_fetch_array($result);
		return $row['name'];
	}
	function get_price($pid){
	global $con;
		$result=mysqli_query($con,"select price from product where id=$pid") or die("select name from product where id=$pid"."<br/><br/>".mysqli_error());
		$row=mysqli_fetch_array($result);
		return $row['price'];
	}
	function remove_product($pid){
	global $con;
		$pid=intval($pid);
		$max=count($_SESSION['cart']);
		for($i=0;$i<$max;$i++){
			if($pid==$_SESSION['cart'][$i]['productid']){
				unset($_SESSION['cart'][$i]);
				break;
			}
		}
		$_SESSION['cart']=array_values($_SESSION['cart']);
	}
	function get_order_total(){
	global $con;
		$max=count($_SESSION['cart']);
		$sum=0;
		for($i=0;$i<$max;$i++){
			$pid=$_SESSION['cart'][$i]['productid'];
			$q=$_SESSION['cart'][$i]['qty'];
			$price=get_price($pid);
			$sum+=$price*$q;
		}
		return $sum;
	}
function addtocart($pid,$q,$psize,$pcolor,$img_name){
	global $con;
		if($pid<1 or $q<1) return;
		if(is_array($_SESSION['cart'])){
			if(product_exists($pid)) return;
			$max=count($_SESSION['cart']);
			$_SESSION['cart'][$max]['productid']=$pid;
			$_SESSION['cart'][$max]['qty']=$q;
			$_SESSION['cart'][$max]['psize']=$psize;
			$_SESSION['cart'][$max]['pcolor']=$pcolor;
			$_SESSION['cart'][$max]['img_name']=$img_name;
			//$_SESSION['cart'][$max]['imgID']=$imgID;
		}
		else{
			$_SESSION['cart']=array();
			$_SESSION['cart'][0]['productid']=$pid;
			$_SESSION['cart'][0]['qty']=$q;
			$_SESSION['cart'][0]['psize']=$psize;
			$_SESSION['cart'][0]['pcolor']=$pcolor;
			$_SESSION['cart'][0]['img_name']=$img_name;
			//$_SESSION['cart'][0]['imgID']=$imgID;
		}
	}
	function product_exists($pid){
	global $con;
		$pid=intval($pid);
		$max=count($_SESSION['cart']);
		$flag=0;
		for($i=0;$i<$max;$i++){
			if($pid==$_SESSION['cart'][$i]['productid']){
				$flag=1;
				break;
			}
		}
		return $flag;
	}

?>