php - write sql from multiple checkbox -


i researched lot , found solution ,probably not convincing solution me.hence posting question,please me

i have checkbox same name , different values like

1.cate.php

<form action="mobile-phones-category.php" method="post">

<input type="checkbox" value="samsung" name="mobile[]"> sams

<input type="checkbox" value="nokia" name="mobile[]"> nolkia

<input type="submit" name="submit" value="submit" class="btn btn-primary pull-right">

</form>

2.) mobile-phones-category.php

i retrieve values of check box on submit[array format] , want search db..i using normal mysql_query(not pdos)

$search=$_post["mobile"]; $search_string = implode(', ', $search); echo $search_string;

here nokia,sams

next write single sql query include('connection.php');

$query = mysql_query("select * tablename titles '%$search_string%' ") or die(mysql_error());

what happening 1 value in array searched , not values in array..what changes should make array element should searched

thanks , regards

use in keyword in query instead of like

$query = mysql_query("select * tablename titles in ($search_string)" ) or die(mysql_error()); 

usage example:

$query = mysql_query("select * tablename titles in ('nokia','sams')" ) or die(mysql_error()); 

this give records title nokia & sams table.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -