I have created the following search bar in order to display the product results. Although I managed to display them in the same page with the search bar, I cant create a redirection from the search bar to another page in order to display the results there.
The Search Bar:
div class="col-sm-3 col-md-3">
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" class="navbar-form" role="search" >
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="searchcriteria">
<div class="input-group-btn">
<button class="btn btn-default" type="submit" name="submit" id="search" value="search"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
The rest of the code (for displaying the results):
if ($_POST['submit']) {
$searchcriteria = (trim($_POST['searchcriteria']) == "")?
die ("You did not enter any search criteria. Try Again!"):
mysqli_real_escape_string($mysqli, trim($_POST['searchcriteria']));
echo "You searched for : " . $searchcriteria;
$query = "select * from album_info where upper(title) like '%". strtoupper($searchcriteria) . "%' or upper(name) like '%" . strtoupper($searchcriteria) . "%'";
if (! ($result = mysqli_query($mysqli,$query)))
die ("There is something wrong in the query :" . $query . "</body></html>");
echo '<table border="1">';
while ($rows = mysqli_fetch_array($result)) {
$title = $rows['title'];
$name = $rows['name'];
$imagefile = $rows['imagefile'];
?>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<img src="<?php echo "img/".$imagefile ?>" />
<div class="caption">
<h3><?php echo $title ?></h3>
<p><?php echo $name ?></p>
<p><a href="#" class="btn btn-primary" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
</div>
</div>
</div>