czukoman20 Posted June 18, 2008 Share Posted June 18, 2008 I have this drop down menu, and i want it to be able to look at what the user has in the database, and then i would like it to show up in the drop down as the default when the user goes into edit account <tr><td>Type of Market:</td> <td><label> <select name="type_market" id="type_market"> <option value="sto">Stocks </option> <option value="com">Commodities</option> <option value="edu">Education</option> <option value="fin">Financial Planning</option> <option value="mort">Mortgages</option> </select> I want to make this take this value <? echo $req_user_info['type_market']; ?> kinda like how you would insert the text that they already have in the text box, but instead for a drop down menu also just a side question.. What mysql query can i use to update a whole column in the database to = 0 help is appreciated thanks Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/ Share on other sites More sharing options...
hitman6003 Posted June 19, 2008 Share Posted June 19, 2008 Have a check for the value in the row for each item in the select: <option value="sto" <?php echo $req_user_info['type_market'] == "sto" ? 'selected="selected" : ''; ?>>Stocks </option> [quote]What mysql query can i use to update a whole column in the database to = 0[/quote] Don't use a WHERE clause... [code]UPDATE table_name SET column = 0; [/code] Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/#findComment-568693 Share on other sites More sharing options...
czukoman20 Posted June 19, 2008 Author Share Posted June 19, 2008 thanks Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/#findComment-568735 Share on other sites More sharing options...
czukoman20 Posted June 19, 2008 Author Share Posted June 19, 2008 <option value="sto" <?php echo $req_user_info['type_market'] == "sto" ? 'selected="selected" : '; ?>>Stocks </option> i get an error message saying that the semicolon is an issue. if its there or isn't there Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/#findComment-569631 Share on other sites More sharing options...
hitman6003 Posted June 19, 2008 Share Posted June 19, 2008 You have some misplaced single quotes. Also, it may help to put the expression in parenthesis: <?php echo ($req_user_info['type_market'] == "sto" ? 'selected="selected"' : ''); ?> Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/#findComment-569649 Share on other sites More sharing options...
czukoman20 Posted June 20, 2008 Author Share Posted June 20, 2008 thanks that worked.. ok well one last question mysql_query(""); What should i input if i want to delete all information from a particular column but still keep the column Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/#findComment-569827 Share on other sites More sharing options...
Stephen Posted June 20, 2008 Share Posted June 20, 2008 You could try doing: mysql_query("UPDATE table SET column=''"); Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/#findComment-569828 Share on other sites More sharing options...
czukoman20 Posted June 20, 2008 Author Share Posted June 20, 2008 ok well i figured it out Link to comment https://forums.phpfreaks.com/topic/110807-mysql-with-drop-down-menu/#findComment-569829 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.