Hi All,
Kinda new to this. I’ve got a MySQL search query working using 2 drop downs, so if white and mermaid or ivory and fishtail is selected, the results are returned successfully. I can’t figure out how to get every color/style to display if nothing is selected in one of the dropdowns. So just selecting ‘white’ should return all white fishtails and mermaids. Any help would be really appreciated ? I’ve put a demo here to show what I mean [url]http://goo.gl/E4vzuM
[code=php]
// Snippet from my PHP…
if (isset($_REQUEST[‘submit’]))
{ // Show results from dropdowns
$drop1 = $_POST[‘search1’];
$drop2 = $_POST[‘search2’];
$query_all = “SELECT * FROM products WHERE `colour` LIKE ‘%”.$drop1.”%’ AND `style` LIKE ‘%”.$drop2.”%'”;
}
else // Show all
{
$query_all = “SELECT * FROM products”;
}
[code=html]
<select name=”search1″ id=”search1″>
<option value=”” selected=”selected”>Please Select</option>
<option value=”white”>white</option>
<option value=”ivory”>ivory</option>
</select>
<select name=”search2″ id=”search2″>
<option value=”” selected=”selected”>Please Select</option>
<option value=”fishtail”>fishtail</option>
<option value=”mermaid”>mermaid</option>
</select>
<input name=”submit” type=”submit” value=”Submit”/>