Using Arrays to populate drop down boxes

I have an array which I taken from mysql database

$skills=“Hazmat Advisor, Fire Investigation, SWAH Level 3”;

I want to mark a select box option as ‘selected’ if the array above matches the options to be selected :

<?php $query1="select skill from officer_skills"; $result1=mysql_query($query1); echo ""; while ($row = mysql_fetch_object($result1)) { echo 'skill == strstr($skills,',', $row->skill)){ echo " selected ";} if($row->skill == strstr($skills, $row->skill)){ echo " selected ";} echo '>' . $row->skill . ''; } echo ""; mysql_free_result($result1); mysql_close(); ?>

The above code will only ‘select’ the first and last option in the array but not the one in the middle ??

Sponsor our Newsletter | Privacy Policy | Terms of Service