CodeIgniter Forums

Full Version: help with multiple input?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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

El Forum

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

El Forum

[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'];
}

El Forum

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

El Forum

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