Welcome Guest, Not a member yet? Register   Sign In
yet another Checkbox problem
#1

[eluser]Unknown[/eluser]
Hello,

This is probably more lack of php knowledge or something but please someone help me out Smile

I have a table full of rows that are fetched from the database. In every row there's a checkbox that user can select and then hit "print selected".

I made a controller "printlabel" And I tried to get the data from database with the ID's that I got from the selected checkboxes.

what kind of query should I do and how do I pass all the data to view file?

Thanks for helping me.
#2

[eluser]xwero[/eluser]
Instead of giving id's to you checkboxes you could do this
Code:
foreach($data as $row)
{
  ?><input type="checkbox" name="print[]" value="<?php echo $row['id']; ?>"><?php
}
When they hit the print selected button you can have following code
Code:
$ids = (isset($_POST['print']))?implode(',',$_POST['print']):'';
if($ids != ''){
$this->db->query('select field1,field2 from table where id in ('.$ids.')');
}
With this code you don't have to use ids for your checkboxes.




Theme © iAndrew 2016 - Forum software by © MyBB