PHP SQL WHERE IN使用implode

时间:2014-07-07 19:00:05

标签: php sql arrays implode where-in

在文件 option-name.php 中,我有一部分复选框代码:

<?php
$query_o_meno = "SELECT meno FROM uctovnictvo GROUP BY meno ORDER BY meno";      
$result_meno  = mysql_query($query_o_meno) or die(mysql_error());ň
?>

<form method="post">

<?php
echo "<strong>Meno:</strong>";
echo "<br />";
while($row = mysql_fetch_array($result_meno)){
 echo "<input type='checkbox' name='option_meno[]' value='".$row['meno']."' checked />" . $row['meno'];
 echo "<br />";
    }
?>

<input type="submit" name="Filtrovat" value="Filtrovat" />
</form>

option-name.php 中的代码由include 'php/option-name.php' ;包含在 second php文件中。这些第二个 php文件也有以下代码:

$sql = "SELECT * FROM uctovnictvo WHERE meno IN ('" . implode('\', \'', $option_meno) . "')   AND  datum BETWEEN '$date_start' AND '$date_end'  ORDER BY $order";   

在我点击按钮FILTROVAT之前,我在第二个php文件中有未定义的变量$option_meno。如何将$result_meno的值定义为$option_meno并且没有问题implode()

谢谢

0 个答案:

没有答案