Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternating table row colors? 1

Status
Not open for further replies.

Baldwin238

Technical User
Feb 23, 2005
68
US
I need help yet once again. I saw a reply by VRagabond to a similar question I have, but I can't seem to implement it correctly in my code.

I want to have alternating table row colors. I was able to code it correctly in .asp, but in php, somethings not clicking. I do use CSS Stylesheets and here is the php code...(The two colors I want the rows to alternate with are, #ffffff and #E2ECFC)

Code:
      <?php 
$file = '[URL unfurl="true"]http://www.freerolls.net/feed.php';[/URL] 
require_once('xml.parser.class.php'); 

$xml = new xml_parser_class(); 
$xml->parseFile($file); 
$tree = $xml->getTree(); 
unset($xml);


print '<table id="main_table" border="1">';
print '<tr><td class="title">Time (Eastern)</td><td class="title">Payouts</td><td class="title">Site</td></tr>';


$i = 0;
foreach($tree['freerolls']['tournament'] as $k)



{
   $i++;
   $k['sitelink'] = str_replace("[URL unfurl="true"]http://www.freerolls.net/fclick/fclick.php?fid=","http://www.absolutelyfreerolls.com/fclick/fclick.php?id=",$k[/URL]['sitelink']);
   print '<tr>';
   print '<td>'.$k['time']['value'].'</td>';
   print '<td>'.$k['payout']['value'].'</td>';
   print '<td><a href="'.$k['sitelink']['value'].'">'.$k['sitename']['value'].'</td>';
   print '</tr>';
}
print '</table>';

?>

Jeff Baldwin
sig2.gif
 
Not having the information about your CSS file, I just have to give the basic idea:

Code:
foreach($tree['freerolls']['tournament'] as $k)
{
    $color = "#E2ECFC";
	if($i%2 == 0) $color="#ffffff"; 
	$i++;
	...
	print "<tr bgcolor=\"$color\">";
    ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top