CodeIgniter Forums
help with multiple input? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: help with multiple input? (/thread-12465.html)



help with multiple input? - El Forum - 10-20-2008

[eluser]newbie boy[/eluser]
how can i make multiple input from a html form inserted on a field in a single user?
i want to have an ouput on mysql table exactly like this:

car_id user_id car
1 1 ford
2 1 honda
3 1 jaguar
1 2 toyota
2 2 suzuki
3 2 audi

has many to one relationship


help with multiple input? - El Forum - 10-20-2008

[eluser]Bramme[/eluser]
Yeah, you'll have to try to explain that a little better. Maybe a form example or so?


help with multiple input? - El Forum - 10-23-2008

[eluser]newbie boy[/eluser]
i got the solution:

in the model this must go:

Code:
// Check to see if there is more than one car
if ( count($data['cars']) > 0 ) {

for($i = 0; $i < count($data['cars']); ++$i) {
$this->CarModel[$i]->car = $data['cars'][$i];
                    
        }
                
    }
// If only one car then
else {
$this->CarModel[0]->car     = $data['cars'];
}



help with multiple input? - El Forum - 10-23-2008

[eluser]manilodisan[/eluser]
This has nothing to do with a model if you ask me...a controller or helper maybe..


help with multiple input? - El Forum - 10-23-2008

[eluser]newbie boy[/eluser]
But if you ask me, all the transactions that deals with the database must go in the model.
Thanks anyway.