我有一個具有大量的複選框,這是從唯一值在MySQL表中生成的一種形式:傳遞值數組從形式到SQL查詢WHERE IN子句
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<?php
$query5="SELECT distinct from_user from tracks WHERE uploaded_page='$this_path_short' ORDER BY from_user";
$result5=mysql_query($query5) or die(mysql_error());
while ($row = mysql_fetch_array($result5)) {
$from_user = $row['from_user'];
echo "<input type=\"checkbox\" name=\"from_user[]\" value=\"AND ".$from_user."\" checked=\"checked\">".$from_user."<br>";
}
?>
<input type="submit" name="submit" value="filter"><br>
我將隨後要通過'from_user'值的數組到另一個MySQL頁面上的查詢。我能得到的值是這樣的:
$names=implode(" ", $_POST['from_user']);
但我不知道如何將這個數組在下面的MySQL查詢:
$query1="SELECT * FROM tracks WHERE from_user IN **array goes here**)";
可能重複[使用IN指令用事先準備好的聲明中搜索(HTTP://計算器.com/questions/9006066/use-the-in-directive-to-search-with-a-prepared-statement) – Gordon 2012-08-11 11:28:14
[PDO with where in queries]的可能重複(http://stackoverflow.com/questions/2373562/pdo-with-where-in-queries) – Gordon 2012-08-11 11:28:51
[MySQL Prepared statement with a variable size variable list]可能的重複(http://stackoverflow.com/questions/327274/mysql-prepared-statements-with-a-variable -size-variable-list) – Gordon 2012-08-11 11:29:15