-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathajax.php
91 lines (57 loc) · 2.02 KB
/
ajax.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
//Including Database configuration file.
include "Auth/connection.php";
include 'Auth/Configuration/Shop_Config.php';
//Getting value of "search" variable from "script.js".
if (isset($_POST['search'])) {
//Search box value assigning to $Name variable.
$Name = $_POST['search'];
//Search query.
$Query = "SELECT * FROM games_selling_db WHERE Games LIKE '%$Name%' LIMIT 5";
//Query execution
$ExecQuery = MySQLi_query($conn, $Query);
//Creating unordered list to display result.
echo '
<ul>
';
//Fetching result from database.
while ($Result = MySQLi_fetch_array($ExecQuery)) {
?>
<!-- Creating unordered list items.
Calling javascript function named as "fill" found in "script.js" file.
By passing fetched result as parameter. -->
<li onclick='fill("<?php echo $Result['Games']; ?>")'>
<?php
$_CONFIG['Games'] = $Result['Games'];
$_CONFIG['Brand'] = $Result['Brand'];
$_CONFIG['Console'] = $Result['Console'];
$_CONFIG['Amount'] = $Result['Amount'];
$_CONFIG['Console_Type'] = $Result['Console_Type'];
$_CONFIG['Shop_Type'] = $Result['Shop_Type'];
$_CONFIG['Item_Type'] = $Result['Item_Type'];
if($_CONFIG['Item_Type'] === "Game"){
$_CONFIG['Item_Type'] = "Games";
}
else
{
}
if($_CONFIG['Console_Type'] === "Console"){
$_CONFIG['Console_Type'] = "Consoles";
}
else
{
}
if($_CONFIG['Games'] == $Result['Games']){?>
<a href="Shop/<?php echo $_CONFIG['Shop_Type']?>/<?php echo $_CONFIG['Console_Type']?>/<?php echo $_CONFIG['Brand']?>/<?php echo $_CONFIG['Console']?>/<?php echo $_CONFIG['Item_Type']?>/<?php echo $_CONFIG['Games']?>.php ">
<!-- Assigning searched result in "Search box" in "search.php" file. -->
<?php echo $Result['Games']; ?>
</a>
<?php
}
?>
</li>
<!-- Below php code is just for closing parenthesis. Don't be confused. -->
<?php
}}
?>
</ul>