my "sizeof" doesn't work - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: my "sizeof" doesn't work (/showthread.php?tid=40848) |
my "sizeof" doesn't work - El Forum - 04-20-2011 [eluser]rikes_denis[/eluser] i tried to get an array data of my checkbox, and when i use sizeof to make limit in my loop, i think it might not work properly this is my code : model Code: $checkBox = $this->input->post('checked'); controller Code: function preview() i dunno if sizeof can work properly in CI or not, can someone help? thanx b4 my "sizeof" doesn't work - El Forum - 04-20-2011 [eluser]CroNiX[/eluser] I think its fine. It looks like your problem is your return is within your loop, so it will only go through the loop once and return no matter how many elements are in the $checkBox array. As a side note, foreach() is faster than using manual iteration... Code: $checkBox = $this->input->post('checked'); my "sizeof" doesn't work - El Forum - 04-20-2011 [eluser]rikes_denis[/eluser] but if i put the return outside the loop, i got nothing to return to the controller, undifined data table. what i try to do is to show the data that i already checked before filtering by id and the data i retrieve from database. this data from database that i try to return is there something i missing or i got the wrong logic? please help sorry my english and thanx for the respon b4 my "sizeof" doesn't work - El Forum - 04-20-2011 [eluser]danmontgomery[/eluser] because you're using where(), so your query looks something like "SELECT * FROM some_table WHERE id_edu = 1 AND id_edu = 2" etc... I'm guessing that id_edu is a primary key, so you're never going to return any results. You want to use either or_where() or where_in(). Something like: Code: $checkBox = $this->input->post('checked'); my "sizeof" doesn't work - El Forum - 04-20-2011 [eluser]rikes_denis[/eluser] great... it works! i need to much..much..much learn and practice thanks nocturn, to share your knowledge to me thank you so much |