-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.inc.php
48 lines (45 loc) · 1014 Bytes
/
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.*,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 ";
}
$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;
}
?>