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
https://forums.phpfreaks.com/topic/90470-multiple-selection-box/
Share on other sites

  • 1 year later...

Archived

This topic is now archived and is closed to further replies.

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