-
Notifications
You must be signed in to change notification settings - Fork 0
/
ajax.php
31 lines (31 loc) · 1.05 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
<?php
//Including Database configuration file.
include "db_connection.php";
//Getting value of "search" variable from "script.js".
if (isset($_POST['search'])) {
//Search box value assigning to $Name variable.
$hpackages_name = $_POST['search'];
//Search query.
$Query = "SELECT hpackages_name FROM home_packages WHERE Name LIKE '%$hpackages_name%' LIMIT 10";
//Query execution
$ExecQuery = MySQLi_query($link, $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['hpackages_name']; ?>")'>
<a>
<!-- Assigning searched result in "Search box" in "search.php" file. -->
<?php echo $Result['hpackages_name']; ?>
</li></a>
<!-- Below php code is just for closing parenthesis. Don't be confused. -->
<?php
}}
?>
</ul>