0

Hello friends,

I have a php page that displays data from a mysql DB. Fields are

1. Username
2. Designation
etc...

I want to list usernames in a listbox. I know thats not a tough job but I want to give different colors (or background color) to usernames with different designation.

ie. All usernames with designation "Teamleader" should have same color and "Manager" should have different color.

Can someone help me?...

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by an00p
0
<?php
while($rows=mysql_fetch_array($result)){
echo "<option value=".$rows['username'].">".$rows['username']."</option>";
}?>

If $rows is "Teamleader" then the font color of $rows should set to blue color.

If $rows is "Manager" then the font color of $rows should set to red color.

I just want to highlight username in listbox according to respective designation.

1

Try this code.

<?php
while($rows=mysql_fetch_array($result))
{
	$style = '';
	if($rows['designation']=="Teamleader")
		$style = 'style="color:#0000FF;"';
	if($rows['designation']=="Manager")
		$style = 'style="color:#cc0000;"';
	
echo "<option value=".$rows['username']." ".$style.">".$rows['username']."</option>";
}
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.