I have table like this
id | type
--- -----
1 | fh
--- -----
2 | fhs
--- -----
3 | so
--- -----
4 | sos
while($row = mysql_fetch_array($res)){
if($row['type'] == "fh" OR $row['type'] == "fhs"){
$name = "Flush Head Studs";
}else if($row['type'] == "so" OR $row['type'] == "sos"){
$name = "Through Standoffs";
}
$category .= '<option value="'.$row['type'].'" name="'.$row['type'].'">' . $name . '</option>';
}
code above is displayng names twice. How can i do that names are only once in list.
your result is correct! if you change your code like this, you can see why …
if you want select all types, i suggest you to add a description or name column to your table … because you youse all of your types as value in the select-field.