Using style in a mysql CONCAT

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Using style in a mysql CONCAT

Post by Lonestarjack »

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>
User avatar
chopsmith
Forum Commoner
Posts: 56
Joined: Thu Nov 13, 2008 10:40 am
Location: Red Bank, NJ, USA

Re: Using style in a mysql CONCAT

Post by chopsmith »

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.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Using style in a mysql CONCAT

Post by Eran »

Code: Select all

 
<select onchange="display_data(this.value);" style="background-color:red;">
 
Or:

Code: Select all

 
<option style="background-color:red;"> </option>
 
User avatar
Lonestarjack
Forum Commoner
Posts: 31
Joined: Tue Nov 11, 2008 7:13 am
Location: Texas

Re: Using style in a mysql CONCAT

Post by Lonestarjack »

I only want the Category part on the "full name" to be red like:
Automotive, Bills Garage
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Using style in a mysql CONCAT

Post by Eran »

You can't style individual parts of an option element
User avatar
chopsmith
Forum Commoner
Posts: 56
Joined: Thu Nov 13, 2008 10:40 am
Location: Red Bank, NJ, USA

Re: Using style in a mysql CONCAT

Post by chopsmith »

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:

Code: Select all

 
a.categoryName {
color: red;
}
 

Code: Select all

 
<option><a class='categoryName'>Automotive</a> Bill's Garage</option>
 
Edit: tried it, doesn't work
Post Reply