Craig wrote:
> I have a database table that holds the values of IDs in the format
> 1,2,3,4,5,67,x,x,x,x,x,x
>
> I am using a dynamic select list menu that displays a list of items
> from a 2nd table with the values set to their unique ids
> eg
> <option vaue =1>item 1</option>
> <option vaue =2>item2</option>
> <option vaue =3>item 3</option>
> <option vaue =4>item 4</option>
> <option vaue =5>item 5</option>
>
> i am trying to use an array search that will highlight the item if the
> option value is in the array of the IDs, but with no luck, either all
> the ids are highlighted or none at all

$ids = '1,2,3,4,5,6,7';  // This value represents the database value

$array_ids = explode( ',', $ids ); // This will give you an array with all
the id's
$amount = 10; // Amount of options

for ( $i = 0; $i < $amount; $i++ )
{
    print '<option value=' . $i;
    if ( in_array( $i, $array_ids ) ) // If the value is in the id's array,
then print selected
       print ' selected';
    print '>' . $i . '</option>';
}

Something like that?

Grtz Erwin


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to