Hi,

I want to know how to search the inputs provided by the user in the form of checkboxes in a mysql database.

<form>
    <input type="checkbox" name="interests" value="Food">
    <input type="checkbox" name="interests" value="Movie">
    <input type="checkbox" name="interests" value="Music">
    <input type="checkbox" name="interests" value="Sports">
    <input type="checkbox" name="interests" value="Reading">
</form>

I have other input elements in the form such as 'text'and 'select'. I am able to search these inputs in the database but not sure how to search checkbox input type.

Thanks

You can write following code in your process page

<?php
$wherecond="";
$sep="";
for ($i=0;$i<count($_POST['interests']);$i++)
{
   $wherecond .= $sep." colname like '%".$_POST['interests']."%' " 
   $sep=" or ";
}


$query="select * from tablename where ". $wherecond;


?>