Jump to content

multiple selection box


suma237

Recommended Posts

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>

Link to comment
Share on other sites

  • 1 year later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.