shadiadiph Posted January 21, 2009 Share Posted January 21, 2009 I have a selection list which is a real mess right now. I have a submit page which I am also using as an edit page so once the message has been submitted there is a page that gives you the options to edit it using the same page it was submitted from. the email addresses are saved in the table. <? $sql = "SELECT * FROM tbladvisorsdetails order by intNameID ASC"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $advisorsid = $row["intNameID"]; $email = $row["email"]; $office = $row["place"]; } ?> which is where the initial email addresses are stored this part seems to work fine the problem is when I am using the page to edit a previously submitted message it displays the correct email address as selected but in the drop down box it also displays lke this. [drop down box] selcted shows [email protected] as that was the email used to send the message originally. Select One [email protected] [email protected] [email protected] [email protected] this is the code i have currently <? $action= $_GET["action"]; if ($action == "resend") { $mid = $_GET["mid"]; $tradesql="select * from tblmaildetails where intMailID=$mid "; $tempdata=$DB_site->query($tradesql); while($row=$DB_site->fetch_array($tempdata)) { $emailadvisor = $row["emailadvisor"]; } } ?> <? $sql = "SELECT * FROM tbladvisorsdetails order by intNameID ASC"; $result = mysql_query($sql); while ($row = mysql_fetch_assoc($result)) { $advisorsid = $row["intNameID"]; $email = $row["email"]; $office = $row["place"]; } ?> <select name="emailadvisor"><option value="" selected="selected">Select One</option> <? $sql = "select email from tbladvisorsdetails order by intNameID ASC"; $temps01=$DB_site->query($sql); while ($row=$DB_site->fetch_array($temps01)) { ?> <? if ($emailadvisor=="") { ?> <option value="<?=$row["email"]?>"><?=$row["email"]?></option> <? } else { ?> <option value="<?=$row["email"]?>"><?=$row["email"]?></option> <option value="<?=$emailadvisor?>" <? if($emailadvisor=="$emailadvisor"){ ?>selected <? } ?>><?=$emailadvisor?> <? } ?> <? } ?> </select> Link to comment https://forums.phpfreaks.com/topic/141697-selection-list-is-a-mess/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.