我有多个选择选项。
<select name="uid" multiple>
<option value="001">001</option>
<option value="002">002</option>
<option value="003">003</option>
</select>
我想在mysql中查询数据。例如,如果我选择uid 001&amp; 003,然后是uid 001&amp;的数据。将显示003。
$get_uid = $_GET['uid'];
$query = mysql_query("SELECT * FROM t_user WHERE uid = '$uid'");
那么如何设置查询多值选择。
答案 0 :(得分:0)
试试此代码
$get_uid = $_GET['uid']; //array
if (count($get_uid) > 0) {
$get_uid = implode(',', $get_uid); //string;
$query = mysql_query("SELECT * FROM t_user WHERE uid IN ($get_uid)");
}
答案 1 :(得分:0)
试试这个......
$get_uid = implode(",",$_GET['uid']);
$query = mysql_query("SELECT * FROM t_user WHERE uid IN ($get_uid)");