john010117 Posted June 19, 2007 Share Posted June 19, 2007 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? Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 19, 2007 Share Posted June 19, 2007 <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!!!! Quote Link to comment Share on other sites More sharing options...
john010117 Posted June 19, 2007 Author Share Posted June 19, 2007 Even though I saw a lot of these <?=$variable?> floating around, I still have no idea what it does. Can you explain it for me? Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 19, 2007 Share Posted June 19, 2007 <?=$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!!! Quote Link to comment Share on other sites More sharing options...
john010117 Posted June 19, 2007 Author Share Posted June 19, 2007 Oh, right. It's just an echo statement. I'm not used to short-hand tags. Sorry. Now I get it. Thank. Quote Link to comment 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.