Hi there,
I am trying to make a list box that has options pulled from a table and by querying another table, add the word SELECTED by the appropriate option. This list box can have multiple values selected.
Recordset rsOptions pulls a complete list of values and their associated labels.
specialist_id = 1,2,5,7,8,9,12
groupname = Law,Medical,Contruction,Computing etc
I have an array 'multi[]' which has values of the items that need to be selected (highlighted).
multi[0] = 4
multi[1] = 7
multi[2] = 9
etc
So my code is as follows
<select name="select[]" size="10" multiple>
<?php
$i=0;
do
{
echo "<option value=".$row_rsOptions['specialist_id']."";
if ($row_rsOptions['specialist_id'] == $multi[$i]) {echo " SELECTED";}
echo ">".$row_rsOptions['group_name']."</option>\n";
$i++;
}
while ($row_rsOptions = mysql_fetch_assoc($rsOptions));
problem is no items are ever highlighted. If I substitute $multi[0] or $multi[1] etc with multi[$i] then one item is marked selected. I can only assume that $i is not being incremented for some reason???
Anyone got any ideas?
TIA
Nick