![]() |
Problems passing data in registration form - 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: Problems passing data in registration form (/showthread.php?tid=53279) |
Problems passing data in registration form - El Forum - 07-17-2012 [eluser]Stromgren[/eluser] Hey CI users ![]() Im currently working on a form which causes me some problems.. Problably me having some troubling figuring out whats arrays and objects in this.. Anyways.. First of all i have a table filled with interests that people can check off in the form. The table has two columns, ID and NAME. So i fetch my interests and in my view i make my checkboxes like this Code: <?php foreach($interests->result() as $interest): ?> In the controller i recieve the data like this: Code: $interests = $this->input->post('interest'); And then i send it, along with some other data, to my model: Code: $this->Registration_model->register_user($username, $email, $password, $country, $city, $interests, $setup, $job, $bio, $activation_code); Now in the model i recieve a user_id from the query which writes all the data except the interests. Now i want to write to another table, users_interests, a row for each interest checked. This row should contain a user_id and a interest_id. Code: ... When i run this i get this error: Quote:Error Number: 1048 So the int_id is empty. As i said, im problably mixing something up when using arrays and objects, but i cant seem to fix this.. Any help is apprecieted Thanks in advance ![]() Problems passing data in registration form - El Forum - 07-17-2012 [eluser]Oscar Dias[/eluser] I think when you do the foreach inside the model the $interest variable is the ID. So in your model it would be like: Code: ... This should do the trick ;-) Problems passing data in registration form - El Forum - 07-17-2012 [eluser]Stromgren[/eluser] [quote author="Oscar Dias" date="1342557335"]I think when you do the foreach inside the model the $interest variable is the ID. So in your model it would be like: Code: ... This should do the trick ;-)[/quote] Yeeeaah !!! You're like a genius ![]() ![]() |