Jump to content

[SOLVED] PHP and option list


john010117

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!!!

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.