0

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.

3
  • 3
    Welcome to Stack Overflow. Please read How to Ask. What have you tried? Could you please post your code? Commented Jan 6, 2016 at 9:39
  • 1
    Can you add code what u tried ? Commented Jan 6, 2016 at 9:40
  • I haven't put code in for it yet, I didn't want to do it and then find out that it wasn't actually possible. What I posted is an example of what I am going to do and was wondering if it is possible to do it. I also tried looking through other posts but couldn't find anything. Sorry for sounding noobish. Commented Jan 6, 2016 at 9:44

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks for that, I will try it out!
With separate values it makes it more time consuming for the users when theyre selecting what car to sell. I made seperate drop down menus for make, model and badge. However, when I've looked at other websites, after they have selected the make, model and badge, there is another dropdown which has multiple values showing [4D SEDAN, AUTOMATIC, 6208 CC, V8]. Wasn't sure how they made this value go into seperate database columns.
separating above will help the user to sell or search for a very specific car. like that you are generalising it. Also it will help you to collect data more easily. a good example of a car selling website is Autotrader.co.uk. everything is separate and distinct.
In www.Autotrader.co.uk click on more options and enter a UK post code if you dont know any use NW8 9AY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.