phppup Posted February 23, 2012 Share Posted February 23, 2012 I'm trying to retrieve data from my DB and have it populate the dropdown values inside a form: echo "<option value='0.00' " . ($array['roastturkey'] == '0.00' ? 'selected="selected"' : '') . ">0</option>";echo "<option value='1.00' " . ($array['roastturkey'] == '1.00' ? 'selected="selected"' : '') . ">1</option>";echo "<option value='2.00'> " . ($array['roastturkey'] == '2.00' ? 'selected="selected"' : '') . ">2</option>";echo "<option value='3.00'> " . ($array['roastturkey'] == '3.00' ? 'selected="selected"' : '') . ">3</option>";echo "<option value='4.00'> " . ($array['roastturkey'] == '4.00' ? 'selected="selected"' : '') . ">4</option>";echo "<option value='5.00'> " . ($array['roastturkey'] == '5.00' ? 'selected="selected"' : '') . ">5</option>";echo "<option value='6.00'> " . ($array['roastturkey'] == '6.00' ? 'selected="selected"' : '') . ">6</option>";echo "<option value='7.00'> " . ($array['roastturkey'] == '7.00' ? 'selected="selected"' : '') . ">7</option>";echo "<option value='8.00'> " . ($array['roastturkey'] == '8.00' ? 'selected="selected"' : '') . ">8</option>";echo "<option value='9.00'> " . ($array['roastturkey'] == '9.00' ? 'selected="selected"' : '') . ">9</option>";echo "<option value='10.00'> " . ($array['roastturkey'] == '10.00' ? 'selected="selected I'm using this code, but cannot get the data that's inside the DB to populate the dropdown value. I want it to get the info from the database so that the option that is saved in the database will be new default when the page is loaded. If I don't change it to the previous info it will update the database with the default option rather then the actual option. Quote Link to comment https://forums.phpfreaks.com/topic/257633-populating-the-dropdown-from-db/ Share on other sites More sharing options...
Shadowing Posted February 23, 2012 Share Posted February 23, 2012 You should use php code tags when posting questions and format it better so its easy for us to read. Quote Link to comment https://forums.phpfreaks.com/topic/257633-populating-the-dropdown-from-db/#findComment-1320459 Share on other sites More sharing options...
AyKay47 Posted February 23, 2012 Share Posted February 23, 2012 phppup: you can continue this conversation on the other thread that you started about this subject. Quote Link to comment https://forums.phpfreaks.com/topic/257633-populating-the-dropdown-from-db/#findComment-1320460 Share on other sites More sharing options...
spiderwell Posted February 23, 2012 Share Posted February 23, 2012 are the options hard coded or in an array? the code you have posted doesnt show dropdown values from a database. Quote Link to comment https://forums.phpfreaks.com/topic/257633-populating-the-dropdown-from-db/#findComment-1320461 Share on other sites More sharing options...
PFMaBiSmAd Posted February 23, 2012 Share Posted February 23, 2012 You already have an active thread for this issue. Stick to that thread so that you don't lose the information about what it is you are doing, where you are getting the data from, and what solutions you have already been given. Edit: if your current problem doing this is actually getting the data from the database, you would need to post the code responsible for getting that data from the database. The code you posted has nothing to do with getting the database value. Quote Link to comment https://forums.phpfreaks.com/topic/257633-populating-the-dropdown-from-db/#findComment-1320462 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.