mardi 14 novembre 2017

Export items based on checkbox selection from dabatase

I have a list of items (userdata) in a table and I have a function to export them, but I would need to edit it, so it exports only items I select using checkbox, not the whole database table. So I have this checkbox in each row, with id as its value.

 <input name='selectbox[]' type='checkbox' value='".$id."'/>

Then there is a button to call the function I've set up in controller.

<a type="submit" name="export" href="Controller/Export">Export</a>

And the function looks something like this:

public function Export() {
$selected=$_POST['selectbox'];
$where="";
foreach($selected as $check){
$where .= $check.",";
$ids= "WHERE id IN $where";
}
$data = SELECT * FROM table $where;
echo $data->name; 

etc.. But the problem is, that it seems like the $_POST['selectbox'] values are not transferred to function in a controller. Where did I go wrong and how can I solve this?

Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire