Page 1 of 1

Clever -Alternating text color

Posted: Tue Dec 21, 2004 5:28 am
by mohson
Guys I already have an alternating rows function on my code but how would I go about making the text alternating as well.

SO I have two colors with the text alternating between each color?? heres my code for alterning row colors -now I want to do the same for text?

Code: Select all

// Define your colors for the alternating rows

$color1 = "#ADD8E6";$color2 = "#E0FFFF";
$color = $color2;echo 

"<table width="50%" border="0" cellpadding="2" cellspacing="2">
    <tr>
		<td><b><small>RecNo</small></b></td>
		<td><b><small>ID</small></b></td>
		<td><b><small>Title</small></b></td>
		<td><b><small>First Name</small></b></td>
		<td><b><small>Surname</small></b></td>
		<td><b><small>Organisation</small></b></td>
		<td><b><center><small>Role</small></center></b></td>
		<td><b><small>Address(1)</small></b></td>
		<td><b><small>Address(2)</small></b></td>
		<td><b><small>City</small></b></td>
		<td><b><small>Post Code</small></b></td>
		<td><b><small>Telephone</small></b></td>
		<td><b><small>Mobile</small></b></td>
		<td><b><small>Fax</small></b></td>
		<td><b><small>Last Contact</small></b></td>
		<td><b><small>Contact Again</small></b></td>
		<td><b><small>Email</small></b></td>
		<td><b><small>Notes</small></b></td>";while ($row =
mysql_fetch_object($sql)) 

{($color==$color2)? $color = $color1 : $color = $color2;


echo "<tr bgcolor="$color"><td>".$count . '</td><td> ' . $row->person_id .'</td><td>'.        
	$row->salutation .'</td><td>'.         
	$row->firstname .'</td><td>'.         
	$row->surname .'</td><td>'.        
 	$row->organisation .'</td><td>'.        
	$row->role.'</td><td>'.       
 	$row->address1 .'</td><td>'.        
	$row->address2 .'</td><td>'.       
 	$row->city .'</td><td>'.       
 	$row->postcode .'</td><td>'.        
	$row->telephone .'</td><td>'.        
	$row->mobile .'</td><td>'.        
	$row->fax .'</td><td>'.        
	$row->dateoflastcontact.'</td><td>'.        
	$row->datecontactagain  .'</td><td>'.       
 	$row->email .'</td><td>'.    
	$row->notes .'</td></tr>';

$count += 1;
}

echo "</table>";

Posted: Tue Dec 21, 2004 6:16 am
by snicolas
if you create a style that will apply to the text, you can do this like:
<style>
color1{color:#CCCC};
color2{color:#DDDD};
</style>

after $color1 = "#ADD8E6";$color2 = "#E0FFFF";
$colorText1 ="color1";
$colorText2 ="color2";

then apply the style to your <td>'s..like <td class=\"$colorText\">
The color of text will match the style you created.

Posted: Thu Dec 23, 2004 6:05 am
by mohson
can you show me how to do this with my code???

Posted: Thu Dec 23, 2004 12:22 pm
by John Cartwright
he did...

Posted: Thu Dec 23, 2004 12:57 pm
by Blade556
I think mohson meant like add it to the code he showed us and make a new post with all of it together.

Posted: Thu Dec 23, 2004 5:12 pm
by timvw
meaby, but we are not the homework club that will do everything...

Posted: Thu Dec 23, 2004 10:14 pm
by Blade556
I agree, but it would've been a nice gesture.

Oh where is the christmas spirit :P

Posted: Fri Dec 24, 2004 10:21 am
by mohson
LOL and after all his name was snicholas!!