Jump to content

Recommended Posts

I just want a simple drop-down list where a specific value is automatically selected according to the data stored in the database.

 

Ex:

<select name="select_blah_1">
    <option name="1" value="1" selected="true">
    <option name="2" value="2" selected="false">
</select>

 

How would I go about doing that?

 

Link to comment
https://forums.phpfreaks.com/topic/56291-solved-php-and-option-list/
Share on other sites

<select name="select_blah_1">

    <option name="1" value="1" selected="true">

    <option name="2" value="2" selected="false">

</select>

 

^^ those are your code

 

 

while($row=mysql_fetch_assoc(put the query result here))

  {

$option='<option name="2" value='.$row[put some result of query].' selected='.$row[put some result of query].'>';

}

 

<select name="select_blah_1">

  <?=$option?>

 

</select>

 

try to understand and debug if comma or dots are the error any way the logic is there thats all you need to do and learn

hope that helps bro

ASTIG!!!!

 

 

<?=$option?>???

 

same as  <? echo $option;?>

 

this variables are what we have above on the while loop remember

 

and wait to understand what my codes really mean do have an idea about php mysql if you do

then it will be easier for you to understand any way ask if theres still bothering you

 

ASTIG!!!

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.