Get values from array, select it ona multiple select list
Posted: Wed Aug 27, 2003 9:01 pm
Hi...
Can anyone help?
I got an array with some names...
Then I got a select list which has all the names..
I'd like to have the names in the array selected "highlighted" on the list..
So far this is what I have done.. I can display the list.. No prob with tht.. but.. nothing seems to be selected..
Could anyone tell me what I am doing wrong?
Thanks alot
any help is really appreciated! 
thnx..
Can anyone help?
I got an array with some names...
Then I got a select list which has all the names..
I'd like to have the names in the array selected "highlighted" on the list..
So far this is what I have done.. I can display the list.. No prob with tht.. but.. nothing seems to be selected..
Could anyone tell me what I am doing wrong?
Thanks alot
Code: Select all
<?php
// The list...
print "<select name=form[prod][] size=12 multiple>";
MuloptionsSearch ($prod, $_SESSION['an_array']); // prints the list
print "</select>";
// The function..
// print selected options from the search function; normal projects are listed
function MuloptionsSearch($prod, $search)
{
foreach($prod as $a_row) // get all the prod_names
{
if($a_row[prod_family]!="special") //for normal projects only
{
print "<option value="$a_row[prod_id]"";
foreach($search as $rows) // "highlight" the names
{
if ($rows == $a_row[prod_id])
{ print "SELECTED"; }
}
print ">$a_row[prod_name]"."</option>\n";
}
}
}
?>thnx..