Is there any way to apply a style to Category in the following so that the Category in the drop down box will show up red?
<select onchange="display_data(this.value);">
<option>Select A Company</option>
<?php
$query="select names_id as id,
CONCAT(ucase(nam_category), ', ', nam_company) AS full_name
FROM names
WHERE nam_type = 'B'
ORDER BY full_name";
$result=mysql_query($query);
while(list($id, $full_name)=mysql_fetch_row($result)) {
echo "<option value=\"".$id."\">".$full_name."</option>";
}
?>
</select>
Using style in a mysql CONCAT
Moderator: General Moderators
- Lonestarjack
- Forum Commoner
- Posts: 31
- Joined: Tue Nov 11, 2008 7:13 am
- Location: Texas
Re: Using style in a mysql CONCAT
I'm not 100% certain, but I don't think you can style options in a <select>. In the past, I've bolded an option, and that only worked in IE.
Re: Using style in a mysql CONCAT
Code: Select all
<select onchange="display_data(this.value);" style="background-color:red;">
Code: Select all
<option style="background-color:red;"> </option>
- Lonestarjack
- Forum Commoner
- Posts: 31
- Joined: Tue Nov 11, 2008 7:13 am
- Location: Texas
Re: Using style in a mysql CONCAT
I only want the Category part on the "full name" to be red like:
Automotive, Bills Garage
Automotive, Bills Garage
Re: Using style in a mysql CONCAT
You can't style individual parts of an option element
Re: Using style in a mysql CONCAT
Well, I guess you can style them in the way pytrin mentions. If I were you, I'd try putting the Category portion inside of href-less anchor tags and give them a class, then style the class:
Edit: tried it, doesn't work
Code: Select all
a.categoryName {
color: red;
}
Code: Select all
<option><a class='categoryName'>Automotive</a> Bill's Garage</option>