Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.