-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.inc.php
48 lines (45 loc) · 1.06 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
<?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=''){
$sql="select product.*,category.category_name from product,category where product.product_status=1 ";
if($cat_id!=''){
$sql.=" and product.category_id=$cat_id ";
}
if($product_id!=''){
$sql.=" and product.product_id=$product_id ";
}
$sql.=" and product.category_id=category.category_id ";
if($search_str!=''){
$sql.=" and (product.name like '%$search_str%' or product.details like '%$search_str%') ";
}
if($sort_order!=''){
$sql.=$sort_order;
}else{
$sql.=" order by product.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;
}
?>