1 回答

TA貢獻1799條經驗 獲得超9個贊
好的,在第一段代碼中創建表單,使用主鍵作為復選框的值:
<div class="tab-pane" id="TLL">
<table class="table table-bordered" style="color: Black" id="table-3">
<?php
$control_info= $this->db->query("select *
from controlsemanal
where vendedora = 'Taller'
and Indicador != '1'
and Indicador !='100'
ORDER BY FIELD (Id_Status,1,3,4,5,6,2,7,0) ");
?>
<thead> etc etc </thead>
<tbody>
<?php
$arr_loop = $control_info;
foreach ($arr_loop->result_array() as $row) {
?>
<tr> <th>
<div>
<input type="checkbox" name="check[]" value="<?php echo $row['referencia']; ?>">
</div>
</th>
etc etc
</tr>
<?php
} // I guess foreach ends here
?>
</tbody>
</table>
然后,在您的第二個表格(處理$ _POST表單)中,僅獲得標記的項目:
check
必須是一個數組,包含 每個標記的項目reference
未標記的復選框不會與表單一起發送
從他們那里列出一個列表以創建過濾器“ref1,ref2,...雷夫克斯”
我猜你的參考列是數字,如果沒有,評論,我會修復查詢
$referencias = (isset($_POST['check'])) ? implode(', ', $_POST['check']) : '';
// Create your query, filtering by $references
$control_info= $this->db->query("select *
from controlsemanal
where vendedora = 'Taller'
and referencia IN ($referencias)
ORDER BY FIELD (Id_Status,1,3,4,5,6,2,7,0) ");
// Create your table here
- 1 回答
- 0 關注
- 149 瀏覽
添加回答
舉報