forked from ChintanNandish/onlineshopmaker_localhost_4
-
Notifications
You must be signed in to change notification settings - Fork 1
/
search_update_product-admin.php
72 lines (70 loc) · 2.05 KB
/
search_update_product-admin.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
<?php
session_start();
$q = $_GET['q'];
if (isset($_GET['c'])){
$ch = $_GET['c'];
}
if (isset($_GET['s'])){
$sub = $_GET['s'];
}
$product_names = $_SESSION["names"];
if (strlen($q)>0) {
$hint="";
$max_count = 0;
$q = preg_replace('/\s+/', '', $q);
if (!isset($_GET['c']) && !isset($_GET['s'])){
for ($i=0; $i<count($product_names); $i++){
if (stristr($product_names[$i][2], $q)){
if ($hint == ""){
$hint = "<a href='update-product-admin.php?pro=".$product_names[$i][2]."&i=".$i."'>".$product_names[$i][2]."</a>";
}
else{
$hint = $hint."<br><a href='update-product-admin.php?pro=".$product_names[$i][2]."&i=".$i."'>".$product_names[$i][2]."</a>";
}
$max_count++;
}
if ($max_count>10){
break;
}
}
}
else if (isset($_GET['c']) && !isset($_GET['s'])){
for ($i=0; $i<count($product_names); $i++){
if ($product_names[$i][0] == $ch && stristr($product_names[$i][2], $q)){
if ($hint == ""){
$hint = "<a href='update-product-admin.php?pro=".$product_names[$i][2]."&i=".$i."'>".$product_names[$i][2]."</a>";
}
else{
$hint = $hint."<br><a href='update-product-admin.php?pro=".$product_names[$i][2]."&i=".$i."'>".$product_names[$i][2]."</a>";
}
$max_count++;
}
if ($max_count>10){
break;
}
}
}
else if(isset($_GET['c']) && isset($_GET['s'])){
for ($i=0; $i<count($product_names); $i++){
if ($product_names[$i][0] == $ch && $product_names[$i][1] == $sub && stristr($product_names[$i][2], $q)){
if ($hint == ""){
$hint = "<a href='update-product-admin.php?pro=".$product_names[$i][2]."&i=".$i."'>".$product_names[$i][2]."</a>";
}
else{
$hint = $hint."<br><a href='update-product-admin.php?pro=".$product_names[$i][2]."&i=".$i."'>".$product_names[$i][2]."</a>";
}
$max_count++;
}
if ($max_count>10){
break;
}
}
}
if ($hint=="") {
$response="no matches found!";
} else {
$response=$hint;
}
echo $response;
}
?>