I want to link searches from a checkbox form together. E.g i have 5 checkboxes (a,b,c,d,e) if i have checked a and b, i want to search depending on what i have searched i.e display two different results.
<form role="form" action="R.php" method="post">
<div class="form-group">
<input type="checkbox" value="a" name="search" />a
<input type="checkbox" value="b" name="search" />b
<input type="checkbox" value="c" name="search" />c
<input type="checkbox" value="d" name="search" />d
<input type="checkbox" value="e" name="search" />e
</div>
<input class="btn btn-default glyphicon-align-right" type="submit" value=">>"/>
</form>
The PHP
<?php $output='';
if(isset($_POST['search'])){
$searchq=$_POST['search'];
$searchq = preg_replace ("#[^0-9a-z]#i","",$searchq);
$Squery = mysql_query("SELECT * FROM database WHERE Name LIKE '%$searchq%'");
$count = mysql_num_rows ($Squery);
echo "<div id=results><ul class=list-group><div id=qwerty>";
if($count == 0){
$output = 'There was no results!';
}else{
while($row = mysql_fetch_array($Squery)){
$name = $row ['Name'];
$id = $row['ID'];
$category = $row['Category'];
$output .='<div class="container">'.$name.$category.' '.$id.'</div>';
echo "<li>"."<div style=height:95px ><h3 class=text-center style=text-transform:capitalize >".$name.' '."</h3></div>".
"<div>"."<a href=n.php><img src=images/$id.jpg alt=Image /></a>
</div>".
' '.$category.' RESULT!!!!!'.$id."</li>";
}
echo "</div></ul></div>";
}
}
?>
Aucun commentaire:
Enregistrer un commentaire