i have a problem in query
i have attached a sql for query and my searching code is following

<div>
<form name="frm" action=search.php method=post>
  <select name="facilities[]" id="facilities[]" style="width: 130px;" multiple="mutiple" size="3">
    <option value="17">Conference hall</option>
    <option value="16">Meeting</option>
    <option value="14">Danceing</option>
    <option value="15">Swimming</option>
    <option value="18">A/c room</option>
    <option value="19">Dining hall</option>
    <option value="20">Cooking facility</option>
    <option value="21">Gardening</option>
    <option value="22">Tempels</option>
  </select>
</div></form>

below is my php code i want to search host which have multiple facilities
means search a host have 17 and 16 facilities
or search a host have 15 and 16 facility

foreach ($_POST['facilities'] as $item){
              $facilities[]=$item;}
$comma_separated = implode(",", $facilities);
if(isset($_POST['facilities']) && (sizeof($facilities) !='0'))
				   	{ 
					  $where.= " where facility in (".$comma_separated.")";
					 } 
$kkc="select * from tblhost " .$where;
		$searchHost=mysql_query($kkc);
		 $searchRow=mysql_num_rows($searchHost);

but i could not find proper result for it

hi,
i checked your code,
your facility field contains 17,16,14,15.
Means these values are not in sorted order. that is the problem..
sort the array while inserting the facility column.

why because mysql IN() function works based on binary search.
binary search needs to be searched array in sorted manner.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.