Question

Darthmaul

Goldbergstein
Joined
Jul 28, 2009
Messages
11,173
Reaction score
4
FP$
6,302
So, I have this script I'm working on for a client. It uses a lot of forms, and in one of the forms I'm submitting information to a customer database. Now, I am using select boxes like so:
select.png


The dilema is: How does one read the value of the select boxes(pre-written) and then submit that to the database without it being messy. For instance: If I selected "cell phone" the database would need to understand that and write that....
I'm thinking there's some kind of conditional here, but I don't want the table to be enormous sooo
 
What i usually do is create a table for the options and set an auto-increment id for it.

In the input field show it like <options value="*id*">*value*</option>

Then when the form is submitted the id of the option should be stored along with the other data. When you get data from database, use a join query to return category name instead of the id stored.

Using this way, you can easily add/edit the dropdown options in future.
 
Back
Top Bottom