matt121400 Posted July 25, 2008 Share Posted July 25, 2008 ok so i am making a form and i need 1 text box from a form to produce 2 seperate entries into the mysql for example when someone picks a state from a drop down menu i would like it to send New York and NY as seperate fields in mysql how would i go about this? i was thinking hidden fields possibly but i am new at this so i am not quite sure how to go about it. Link to comment https://forums.phpfreaks.com/topic/116531-form-php-mysql-problem/ Share on other sites More sharing options...
TransmogriBenno Posted July 25, 2008 Share Posted July 25, 2008 Why do you want to do that? I think a better solution would be to store the short (e.g. NY) and long (e.g. New York) names in, say, a 'States' table the database, and then reference them using a key. You could use the short name as the key. Link to comment https://forums.phpfreaks.com/topic/116531-form-php-mysql-problem/#findComment-599183 Share on other sites More sharing options...
matt121400 Posted July 25, 2008 Author Share Posted July 25, 2008 i have a program that needs it to do it the way i described so ya.. Link to comment https://forums.phpfreaks.com/topic/116531-form-php-mysql-problem/#findComment-599184 Share on other sites More sharing options...
vikramjeet.singla Posted July 25, 2008 Share Posted July 25, 2008 you may use as: <option value="NY:New York">New York</option> when you will store this in database just explode and save enjoy Link to comment https://forums.phpfreaks.com/topic/116531-form-php-mysql-problem/#findComment-599186 Share on other sites More sharing options...
$username Posted July 25, 2008 Share Posted July 25, 2008 What I do to make things fast for programing is add the states to a table in mysql. Like this StateFullName |StateAb | StateID ALABAMA |AL | 1 From there I just do a query on the tables and pull back what is needed. <tr> <td><strong>State:</strong></td> <td> <select name=\"AccountState\" size=\"1\">"; $sql149 = "SELECT StateFullName, StateAb FROM states"; if ($result149 = mysql_query($sql149)) { while ($row149 = mysql_fetch_assoc($result149)) { $selected = ($row149['StateAb']==$Wisconsin)?" selected=\"selected\"":""; echo "<option value=\"{$row149['StateAb']}\"{$selected}>{$row149['StateFullName']}</option>"; } } echo " </select> </div></td> </tr> Link to comment https://forums.phpfreaks.com/topic/116531-form-php-mysql-problem/#findComment-599189 Share on other sites More sharing options...
matt121400 Posted July 25, 2008 Author Share Posted July 25, 2008 ok well my situation is kinda wierd im using a macro program and would like to pull the info from 1 table and some of the things the macro fills out has NY and MN and so on for their drop down menus and some have New york and Minnesota as the choices so what i would need is to have Mn in 1 colum and Minnesota in the next column as i am writing each sites macro individually and can pick and chose which column goes in which site anyway so ya that is why i need it Link to comment https://forums.phpfreaks.com/topic/116531-form-php-mysql-problem/#findComment-599192 Share on other sites More sharing options...
TransmogriBenno Posted July 25, 2008 Share Posted July 25, 2008 You can do that with my solution with a JOIN. If you really want to store the two columns in the same table, then vikramjeet.singla already gave you the answer, eh? Link to comment https://forums.phpfreaks.com/topic/116531-form-php-mysql-problem/#findComment-599206 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.