Forum Moderators: coopster
Now that you have added a couple of listing you want the users to be able to search by the features so if only 2 out of 5 listings are equipped with Anti-Lock brakes it will only pull up those 2 listings.
I have scratched my head over this one. I am only using one item to ease readability. I hope it works.
I have a database column that contains a serialized dataset
serialize($_POST["features"]) the features id is entered from addlisting.php. It is pulled out in a select list with the name = id
a:1:{i:0;s:2:"16";}
I then have a search page which has a multi field select box that passes an array to the script
features[] this posts to listings.php
Array ( [0] => 16 )
this then builds a querystring
if (!empty($_POST["make"])) {
if (!empty($addOnSQL))
$addOnSQL.=" AND ";
$addOnSQL.="make = '" . $_POST["make"] . "'";
}
if (!empty($_POST["features"])) {
if (!empty($addOnSQL))
$addOnSQL.=" AND ";
$addOnSQL.="features = '" . $_POST["features"] . "'";
}
so this is my query
$sql = "SELECT * FROM listings WHERE $addOnSQL";
Is there a way to check if the passed value exists in the serialized dataset? basically does item 16 exist in the column with the serialized dataset? if it doesn't skip pulling this record if it does pull the record and add it to the recordset.
Keep in mind there may be up to 10 or so items being searched on
Thanks for any help
Best Regards,
Brandon