suma237 Posted February 11, 2008 Share Posted February 11, 2008 check the below code...Problem is that I'm unable to display 2 value's selected in the drop down.The drop down will showing only last id from the variable ($REPORTTO= "0003,0004".why?how can i solve this? <code> <? $REPORTTO = "0003,0004"; //echo "Reported To<br>".$REPORTTO;echo "<br>"; $sql_repto = "SELECT a.AtxUserID,a.AtxUserName FROM uniuserprofile a,unigroupdetails b WHERE a.AtxUserID = b.ugdContactID "; $result1 = mysql_query($sql_repto) or die("Could not select"); echo " <select name='reportto[]' multiple>"; echo" <option value='0'>Please Select</option>"; while($row=mysql_fetch_array($result1)) { $AtxUID = $row['AtxUserID']; $AtxUName = $row['AtxUserName']; $arraybreak = explode(",", $REPORTTO); $arrayLength= count($arraybreak); for($p=0; $p <= $arrayLength-1; $p++) { if ($AtxUID == $arraybreak[$p]) { // set the variable $selected to selected if records match $strSelected ="selected"; } else { // leave it blank if records not found $strSelected=""; } } //end of for echo "<OPTION VALUE=".$AtxUID ." $strSelected> ".$AtxUName."</OPTION>"; }//end of while echo"</select>"; ?> </code> Quote Link to comment Share on other sites More sharing options...
suma237 Posted February 11, 2008 Author Share Posted February 11, 2008 problem solved... Quote Link to comment Share on other sites More sharing options...
Julian Posted August 6, 2009 Share Posted August 6, 2009 Hello! Sorry for open this post. But I have the same situation. only the last record is selected. Does anyboby know how to solve it? Regards Quote Link to comment Share on other sites More sharing options...
Julian Posted August 6, 2009 Share Posted August 6, 2009 This is driving me nuts... any hint... please 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.