【发布时间】:2018-08-18 18:15:04
【问题描述】:
这是我的过程
$sec_id = implode(', ', $_POST['sec_id']);
$stmtSec = $crud->runQuery("SELECT * FROM tbl_section WHERE sec_id IN (':sec_id')");
$stmtSec->execute(array(":sec_id" => $sec_id));
while ($rowSec = $stmtSec->fetch(PDO::FETCH_ASSOC))
{
$section[] = $rowSec['section'];
}
但是使用我的代码没有任何显示。
这是我的多选代码。
<select name="sec_id[]" data-live-search="true" class="selectpicker form-control border-input" style="text-align-last:center;" title="Select Section" required multiple>
<?php
$stmtSection = $crud->runQuery('SELECT * FROM tbl_section ORDER BY sec_id DESC');
$stmtSection->execute();
while($rowSection=$stmtSection->fetch(PDO::FETCH_ASSOC))
{
print("<option value='".$rowSection['sec_id']."'>".$rowSection['section']."</option>");
}
?>
</select>
还有另一种在数据库中选择多个的方法吗?或查询? 请帮忙。
【问题讨论】:
-
also:
implode(', ', $rowSec['section'])暗示tbl_section .section是一个数组,这在关系数据库中是一件非常奇怪的事情 -
你能举个例子吗