Hi
I`m wanting to have a refined search where you can have different checkboxes on a form for fields to search from i e
search for a car less than £500, aircon, leather, CD using checkboxes could anyone help me with this? I have the checkboxes in an array but not sure how to pull the info from the database.
Thanks
search a mysql database using checkboxes
Moderator: General Moderators
What you are aiming to achieve is to build a (SQL) Statement to pass to the Database.
Essentially a string.
So you would have sub-strings stored which you would include if the relevant checkbox is checked.
A very brief example, for the receiving page:
Essentially a string.
So you would have sub-strings stored which you would include if the relevant checkbox is checked.
A very brief example, for the receiving page:
Code: Select all
<?php
$sql = "SELECT * FROM cars"
if (isset($_POST['chkbox1']) {
$sql .= " WHERE airCon = 1";
}
mysql_query($sql);
?>