<?php include "header.php"; ?>
<div id="page-wrapper">
<div class="container-fluid">
<!-- Page Heading -->
<div class="row">
<div class="col-lg-12">
<?php
$query = $_GET['query'];
$min_length = 1;
if(strlen($query) >= $min_length)
{
$query = htmlspecialchars($query);
$query = mysqli_real_escape_string($con, $query);
echo "<h4>Your match result(s) for <font color=#B22222>$query</font></h4>
<hr>";
//select 2 tables - search
$result = mysqli_query($con, "SELECT category_name, image, category_id, datetime, description, category_id FROM category
WHERE (`category_name` LIKE '%" .$query. "%')
UNION SELECT product_name, image, product_id, datetime, description, category_id FROM products WHERE (`product_name` LIKE '%" .$query. "%' )
UNION SELECT username, fname, lname, email, contact, user_id FROM users WHERE (`username` LIKE '%" .$query. "%' )
") or die(mysqli_error());
if (mysqli_num_rows($result) > 0)
{
while($info = mysqli_fetch_array($result))
{
echo ""; ?>
<?php Print "" ?>
<div class="row">
<div class="col-md-7">
<a href="#">
<img width="280" height="250" src="<?php echo $info['image']; ?>" alt="">
</a>
</div>
<div class="col-md-5">
<?php
if (strpos($info, '') === true)
{ Print "<h4><a href='view_cat.php?category_id=".$info['category_id']."'>".$info['category_name']."</a></h4>"; }
else if (strpos($query, 'username') === true)
{ Print "<h4><a href='view_cat.php?category_id=".$info['category_id']."'>".$info['username']."</a></h4>"; }
?>
<hr>
<h4>Added at: <?php echo date("d-M-Y", strtotime($info['datetime'])); ?></h4>
<h4>Description: <?php echo $info['description']; ?></h4>
</div>
</div>
<?php "";
}
}
else {
echo "<p>
<img src='../image/alert.png'><br />
<h4>Sorry... No results for $query</h4>";
echo "";
}
}
else{
echo "<h4>Search empty field. Please input your category name</h4>";
}
?>
</div>
</div>
<!-- /.row -->
</div>`enter code here`
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->`enter code here`
<?php include "footer.php"; ?>