0

I have a search form where there are multiple checkboxes as inputs:

<input type="checkbox" name="search[]" value="pool">pool</input>
<input type="checkbox" name="search[]" value="pc">pc</input>

Now, based on the above check boxes, if I select both the values (pool and pc), everything starting both "pool" and "pc" has to be retrieved in all combinations--like POol,POOl,pOOl,Pc, etc. This needs to occur server-side in PHP.

How do I dynamically search from the database for all combinations? Can I somehow use the answers to the question "Mysql Like multiple values"?

Community
  • 1
  • 1
codelover
  • 317
  • 1
  • 11

1 Answers1

0

The MySQL Code below will return results that match any or your search terms stored in $_POST['search']. Since MySQL matches text in a case insensitive manner there is not additional step to match the different case of $_POST['search'].

<?php
  $sql = sprintf("SELECT * FROM tbl WHERE col IN ('%s')", implode("','",$_POST['search']) );

sprintf

implode

Binary Alchemist
  • 1,600
  • 1
  • 13
  • 28