cedtech23 Posted November 30, 2007 Share Posted November 30, 2007 I was able to get information out of a table. know I am trying to dynamically populate a drop down menu. I am having some trouble populating the option value with $row['f_name'] " " $row['l_name'] The same issue with the option display name. The syntax is not correct, please advise. select name="provider" id="provider"> <option></option> <?php while($row = mysql_fetch_array($result)) { echo '<option value="'.$row['l_name'].'"'.$selected.">{$row['f_name']}{$row['l_name']}</option>\n"; } ?> </select> Quote Link to comment Share on other sites More sharing options...
Stooney Posted November 30, 2007 Share Posted November 30, 2007 What is the expected output? give me an example of what it should look like. I didnt quite understand what it is you want it to look like. Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted November 30, 2007 Share Posted November 30, 2007 Try like this select name="provider" id="provider"> <option></option> <?php while($row = mysql_fetch_array($result)) { // store in a variable $lastname = $row['l_name']; $firstname = $row['f_name']; // echo the variables... echo '<option value="'.$lastname.'"'.$selected.'">'.$firstname.' '.$lastname.'</option>\n'; } ?> </select> Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 30, 2007 Share Posted November 30, 2007 <select name="provider" id="provider"> <option></option> <?php while($row = mysql_fetch_array($result)) { // store in a variable $lastname = $row['l_name']; $firstname = $row['f_name']; // echo the variables... echo '<option value="'.$lastname.'" '.$selected.'>'.$firstname.' '.$lastname.'</option>\n'; // have a space between $lastname and $selected } ?> </select> have a space between $lastname and $selected.. also, is $selected defined? you were also missing a < at the beginning of the code 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.