-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.inc.php
77 lines (69 loc) · 1.9 KB
/
functions.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
function pr($arr){
echo '<pre>';
print_r($arr);
}
function prx($arr){
echo '<pre>';
print_r($arr);
die();
}
function get_safe_value($con,$str){
if($str!=''){
$str=trim($str);
return mysqli_real_escape_string($con,$str);
}
}
function get_product($con,$limit='',$cat_id='',$product_id='',$search_str='',$sort_order='',$is_best_seller='',$sub_categories=''){
$sql="select product.*,categories.categories from product,categories where product.status=1";
if($cat_id!=''){
$sql.=" and product.categories_id=$cat_id ";
}
if($product_id!=''){
$sql.=" and product.id=$product_id ";
}
if($sub_categories!=''){
$sql.=" and product.sub_categories_id=$sub_categories ";
}
if($is_best_seller!=''){
$sql.=" and product.best_seller=1 ";
}
$sql.=" and product.categories_id=categories.id ";
if($search_str!=''){
$sql.=" and (product.name like '%$search_str%' or product.description like '%$search_str%') ";
}
if($sort_order!=''){
$sql.=$sort_order;
}else{
$sql.=" order by product.id desc ";
}
if($limit!=''){
$sql.=" limit $limit";
}
//echo $sql;
$res=mysqli_query($con,$sql);
$data=array();
while($row=mysqli_fetch_assoc($res)){
$data[]=$row;
}
return $data;
}
function wishlist_add($con,$uid,$pid){
$added_on=date('Y-m-d h:i:s');
mysqli_query($con,"insert into wishlist(user_id,product_id,added_on) values('$uid','$pid','$added_on')");
}
function ProductSoldQtyByProductId($con,$pid){
$sql="select sum(order_detail.qty) as qty from order_detail,`order` where
`order`.id=order_detail.order_id and order_detail.product_id=$pid and
`order`.order_status!=4";
$res=mysqli_query($con,$sql);
$row=mysqli_fetch_assoc($res);
return $row['qty'];
}
function ProductQty($con,$pid){
$sql="select qty from product where id='$pid'";
$res=mysqli_query($con,$sql);
$row=mysqli_fetch_assoc($res);
return $row['qty'];
}
?>