Jump to content

populating the dropdown from DB


phppup

Recommended Posts

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/257633-populating-the-dropdown-from-db/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.