34 lines
No EOL
1.2 KiB
PHP
34 lines
No EOL
1.2 KiB
PHP
<?php
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
//Including Database configuration file.
|
|
if (isset($_POST['search'])) {
|
|
//Search box value assigning to $Name variable.
|
|
$Name = $_POST['search'];
|
|
//Search query.
|
|
$Query = $GLOBALS['mysql']->query("SELECT * FROM fazs WHERE name LIKE '%$Name%' OR name2 LIKE '%$Name%'LIMIT 40");
|
|
//print_r( $Query);
|
|
echo $con;
|
|
//Query execution
|
|
$ExecQuery = MySQLi_query($con, $Query);
|
|
//Creating unordered list to display result.
|
|
echo '
|
|
<ul>
|
|
';
|
|
//Fetching result from database.
|
|
//while ($Result = MySQLi_fetch_array($ExecQuery)) {
|
|
//while ($Result = MySQLi_fetch_array($Query)) {
|
|
while($Result = $Query->fetch_assoc()) {
|
|
?>
|
|
<!-- 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['name2'].' '.$Result['name']; ?>")'>
|
|
<a>
|
|
<!-- Assigning searched result in "Search box" in "search.php" file. -->
|
|
<?php echo $Result['name2'].' '.$Result['name']; ?>
|
|
</li></a>
|
|
<!-- Below php code is just for closing parenthesis. Don't be confused. -->
|
|
<?php
|
|
}}
|
|
?>
|
|
</ul>
|