Welcome to WebmasterWorld Guest from 50.17.117.221

Forum Moderators: open

Message Too Old, No Replies

Storing Data in MySQL

     
10:12 pm on Nov 26, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 3, 2010
posts: 16
votes: 0


Hello,

I have a form that combines java script and php to make calculations and then stores them in a database. On my tables, i have different options the user can select. For example, the 2 ton Unit has a value of 1492.
<option value="1492">2 Ton Unit</option>

My problem is that when values are being passed on to the database, it automatically passes the "value" instead of the name which makes sense. However, I would like "2 Ton Unit" to be stored instead of the number. Any suggestions to make this happen? I then send an email to the user with his/her selections and all they see is numbers which don't make a lot of sense.

Thanks people.
11:16 pm on Nov 30, 2010 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5550
votes: 24


Create a lookup table that matches the numeric value with the text description. Something like:
UnitID Description
------ -----------
1492 2 Ton Unit

In most cases, you want to store the actual numeric value in your database- numeric values are faster to search and you don't need to change all your data if the description changes (you just make one change in the lookup table).
7:49 am on Dec 3, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 3, 2010
posts: 16
votes: 0


hello and thanks for your reply. could you please take a look at my new post. i think i have explained my problem a little better. thanks

[webmasterworld.com...]