Welcome Guest, Not a member yet? Register   Sign In
help with multiple input?
#1

[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
#2

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

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

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

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




Theme © iAndrew 2016 - Forum software by © MyBB