Brandon
Brandon

Reputation: 1

Multiple values in the select field going into multiple database columns

i'm kind of new to coding so I came here for help.

I'm making a website and I've done all the variables correctly prior to this and everything is working but I'm a bit lost on one part.

I have a select field that shows [4D SEDAN, AUTOMATIC, 6208 CC, V8]

Am I able to do some code that makes; - 4D go into the 'Doors' column - SEDAN go into the 'Body' column - AUTOMATIC go into the 'Transmission' column - 6208 CC go into the 'Engine Size' column - V8 go into the 'Cylinders' column

Appreciate any help.

Upvotes: 0

Views: 52

Answers (1)

Daniel PurPur
Daniel PurPur

Reputation: 529

Anything is possible BUT! That is not a write way of doing it but if you insist you can use if and else statement!

// To separate 4D and SEDAN you must write a strpos() or a regex!
if ($selectValue == '4D SEDAN'){
 $doorsColumn = $selectValue;
}elseif($selectValue == 'AUTOMATIC'){
 $TransmissionColumn = $selectValue;
}

Best way is to have a separate dropdown menu for each category.

Upvotes: 1

Related Questions