Page 1 of 2

[Solved] Alternate table row colours

Posted: Wed Jun 08, 2005 10:41 am
by Addos
I have a table (below) that returns table rows from my database. I want to run some sort of loop that will give me alternative colours for every odd row. For example every first row blue and every second row red. I have no idea how to approach this and I’d be most grateful for any help.
Thanks
Brian

Code: Select all

<?php do { ?>
		  <? $TotalScore = $row_get250Results['cookstown']   +
   $row_get250Results['tandragee']   +
   $row_get250Results['northwest']   +
   $row_get250Results['athea']       +
   $row_get250Results['skerries']    +
   $row_get250Results['southern']    +
   $row_get250Results['walderstown'] +
   $row_get250Results['kells']       +
   $row_get250Results['midantrim']   +
   $row_get250Results['ugp']         +
   $row_get250Results['killalane']   +
   $row_get250Results['scarborough']; ?>
          <tr>
            <td><p><?php echo $row_get250Results['f_name']; ?></p></td>
            <td><p><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td align="center"><p><? echo $TotalScore?></p>
              </td>
          </tr>
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>

Posted: Wed Jun 08, 2005 10:58 am
by Syranide
how about?

Code: Select all

$row = 0
// loop
  $row++;
  if( $row % 2 == 0 )
    // even
  else
    // odd
// endloop
EDIT: and you should not use a do with while at the end for databases, as you could be getting zero rows (possible sorted out, but still), instead, have the while first which makes sure there are rows... otherwise you COULD get a NULL for the first loop.

Posted: Wed Jun 08, 2005 11:22 am
by scorphus
mmmm... well, perhaps this might be a better solution:

Code: Select all

<?php
$suffixes = array('_even', '_odd');
$iter = 0;
do {
   $classSuffix = $suffixes[++$iter % 2];
?>
   <? $TotalScore = $row_get250Results['cookstown']   +
   $row_get250Results['tandragee']   +
   $row_get250Results['northwest']   +
   $row_get250Results['athea']       +
   $row_get250Results['skerries']    +
   $row_get250Results['southern']    +
   $row_get250Results['walderstown'] +
   $row_get250Results['kells']       +
   $row_get250Results['midantrim']   +
   $row_get250Results['ugp']         +
   $row_get250Results['killalane']   +
   $row_get250Results['scarborough']; ?>
          <tr>
            <td class="simple<?php echo $classSuffix; ?>"><p><?php echo $row_get250Results['f_name']; ?></p></td>
            <td class="simple<?php echo $classSuffix; ?>"><p><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center" class="innerborder<?php echo $classSuffix; ?>"><p><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center" class="innerborder<?php echo $classSuffix; ?>"><p><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center" class="innerborder<?php echo $classSuffix; ?>"><p><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center" class="innerborder<?php /* ON_AND_ON */ ?>"><p><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td class="simple<?php echo $classSuffix; ?>" align="center"><p><? echo $TotalScore?></p>
              </td>
          </tr>
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
Create (or inherit) some new classes (simple_even, simple_odd, innerborder_even and innerborder_odd) in your CSS file (or your <style> tag block) which will differ in background color. Then you may have a go. I hope that helps.

-- Scorphus

Posted: Wed Jun 08, 2005 11:40 am
by Burrito
easiest way I know:

Code: Select all

<style>
.black
{
color:#000000;
}
.red
{
color:#ff0000;
}
</style>
<?
$change = TRUE;
while($row = yadayada){
  echo "<tr class=\"".($change ? "black" : "red")."\"><td>stuff</td></tr>";
  $change = !$change;
}
?>
edit: the same thing as JCart posted this does...just another way of doing it it is

Posted: Wed Jun 08, 2005 12:04 pm
by pickle
Even simpler:

Code: Select all

while($row =  blahblah)
{
  $class = ($class == 'red') ? 'black' : 'red';

  echo "<tr class = '$class'><td></td></tr>";
}

Posted: Wed Jun 08, 2005 3:28 pm
by Addos
Thanks to all of you for your help.
At the moment while very appreciative of all the help but I’m still frustrated or just thick as I can’t seem to get anything working. So far I have tried this:

Code: Select all

<table width="100%" border="1">
  <tr>
  <td><h2>250 Championship</h2></td>
  </tr>
  <tr><td>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
<?php  $suffixes = array('_even', '_odd');$iter = 0;
		  do { $classSuffix = $suffixes[++$iter % 2]; ?> 
  <tr align="center">
            <td><h1>Name</h1></td>
            <td><h1>&nbsp;</h1></td>
            <td><h1>Cookstown</h1></td>
            <td><h1>Tandragee</h1></td>
            <td><h1>NW200</h1></td>
            <td><h1>Athea</h1></td>
            <td><h1>Skerries</h1></td>
            <td><h1>Southern</h1></td>
            <td><h1>Walderstown</h1></td>
            <td><h1>Kells</h1></td>
            <td><h1>Faugheen</h1></td>
            <td><h1>Mid-Antrim</h1></td>
            <td><h1>UGP</h1></td>
            <td><h1>Killalane</h1></td>
            <td><h1>Scarborough</h1></td>
            <td><h1>Total</h1></td>
  </tr>
          <?php do { ?>
		  <? $TotalScore = $row_get250Results['cookstown']   +
$row_get250Results['tandragee']   +
   $row_get250Results['northwest']   +
   $row_get250Results['athea']       +
$row_get250Results['skerries']    +
$row_get250Results['southern']    +
$row_get250Results['walderstown'] +
$row_get250Results['kells']       +
$row_get250Results['midantrim']   +
$row_get250Results['ugp']         +
$row_get250Results['killalane']   +
$row_get250Results['scarborough']; ?> 
          <tr>
            <td><p><?php echo $classSuffix; ?><?php echo $row_get250Results['f_name']; ?></p></td>
            <td><p><?php echo $classSuffix; ?><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center" class="simple"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $classSuffix; ?><?php echo $TotalScore?></p>
              </td>
          </tr>
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
</table>
</td>
</tr>

</table> <?php } ; ?>
But I keep getting various errors most notably:
“Parse error: syntax error, unexpected ';', expecting T_WHILE in C:\Inetpub\wwwroot\two_stroke\TMPuo6p6hs8gf.php on line 115”

I have also added to my CSS the following to support the above:

Code: Select all

.trOne {
	background-color: #0000FF;
}
.trTwo {
	background-color: #990000;
}
I then went on and tried this:

Code: Select all

<table width="100%" border="1">
  <tr>
  <td><h2>250 Championship</h2></td>
  </tr>
  <tr><td>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr align="center">
            <td><h1>Name</h1></td>
            <td><h1>&nbsp;</h1></td>
            <td><h1>Cookstown</h1></td>
            <td><h1>Tandragee</h1></td>
            <td><h1>NW200</h1></td>
            <td><h1>Athea</h1></td>
            <td><h1>Skerries</h1></td>
            <td><h1>Southern</h1></td>
            <td><h1>Walderstown</h1></td>
            <td><h1>Kells</h1></td>
            <td><h1>Faugheen</h1></td>
            <td><h1>Mid-Antrim</h1></td>
            <td><h1>UGP </h1></td>
            <td><h1>Killalane</h1></td>
            <td><h1>Scarborough</h1></td>
            <td><h1>Total</h1></td>
  </tr>
<?php do { ?>
   <? $TotalScore = $row_get250Results['cookstown']   +
   $row_get250Results['tandragee']   +
   $row_get250Results['northwest']   +
   $row_get250Results['athea']       +
   $row_get250Results['skerries']    +
   $row_get250Results['southern']    +
   $row_get250Results['walderstown'] +
   $row_get250Results['kells']       +
   $row_get250Results['midantrim']   +
   $row_get250Results['ugp']         +
   $row_get250Results['killalane']   +
   $row_get250Results['scarborough']; 
   
while($row =  row_get250Results)
{
  $class = ($class == 'trTwo') ? 'trOne' : 'trTwo';
  //echo "<tr class = '$class'><td></td></tr>
  echo ?> "<tr class = '$class'>
}          
            <td ><p><?php echo $row_get250Results['f_name']; ?></p></td>
            <td ><p><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td align="center"><p><? echo $TotalScore?></p>
          </td>
          </tr>"
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
</table><? ; } ?>
</td>
</tr>
</table>
But again the among the many errors I get this is just one:

“Parse error: syntax error, unexpected ';' in C:\Inetpub\wwwroot\two_stroke\TMPuq52lhs8iy.php on line 98”

Sorry for the amount of code and the cry for help again but rather than give up I’d prefer to ask for more help.
Thanks very much
Brian

Posted: Wed Jun 08, 2005 4:06 pm
by pickle
Not sure which line is line 98 in your code, but I'd fix line 43 of the very last chunk of code you posted.

Code: Select all

echo ?&gt; &quote;&lt;tr class = '$class'&gt;

Code: Select all

echo &quote;&lt;tr class = '$class'&gt;&quote;;

Posted: Wed Jun 08, 2005 4:43 pm
by Addos
Thanks for you reply.
What is puzzling me is when you posted echo "<tr class = '$class'><td></td></tr>"; is how do I get this to fit into the code below?
This is where in my most recent post I was stuck and although I have made the changes you suggested I still get an error. If I’m to fit all the code between "<tr class = '$class'><td></td></tr>"; I thought that I’d need to use <? in various places in order to keep the HTML separate from PHP...no?
Thanks again
Brian

Code: Select all

while($row =  row_get250Results)
{
  $class = ($class == 'trTwo') ? 'trOne' : 'trTwo';
  //echo "<tr class = '$class'><td></td></tr>
  echo "<tr class = '$class'>" 
          
            <td ><p><?php echo $row_get250Results['f_name']; ?></p></td>
            <td ><p><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td align="center"><p><? echo $TotalScore?></p>
          </td>
          </tr>
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
</table> <?php } ?>

Posted: Wed Jun 08, 2005 5:08 pm
by pickle
How much you integrate PHP and HTML is a matter of debate. Personally, I usually have them heavily integrated. You can, of course, use PHP to output HTML if wanted. My code only ever has one opening PHP and one closing PHP tag. But.. to each their own.

Anyway, just amend what I added last time and make it:

Code: Select all

echo &quote;&lt;tr class = '$class'&gt;&lt;tr&gt;&quote;;?&gt;

Posted: Thu Jun 09, 2005 1:35 am
by Addos
Thanks again for your patience with me.
I have tried over and over but I still keep getting the error message “Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Inetpub\wwwroot\two_stroke\TMPbn2tht0qk.php on line 100” when I try to the code below. I really don’t know what this error means but if I simply try and run this test without any php and just table rows hard coded it works. Once I place <?php echo $row_get250Results['cookstown']; ?> into the string this error immediately pops up.
What is causing this do you know?
Thanks again
Brian

Code: Select all

<table width="100%" border="1">
  <tr>
  <td><h2>250 Championship</h2></td>
  </tr>
  <tr><td>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr align="center">
            <td><h1>Name</h1></td>
            <td><h1>&nbsp;</h1></td>
            <td><h1>Cookstown</h1></td>
            <td><h1>Tandragee</h1></td>
            <td><h1>NW200</h1></td>
            <td><h1>Athea</h1></td>
            <td><h1>Skerries</h1></td>
            <td><h1>Southern</h1></td>
            <td><h1>Walderstown</h1></td>
            <td><h1>Kells</h1></td>
            <td><h1>Faugheen</h1></td>
            <td><h1>Mid-Antrim</h1></td>
            <td><h1>UGP </h1></td>
            <td><h1>Killalane</h1></td>
            <td><h1>Scarborough</h1></td>
            <td><h1>Total</h1></td>
  </tr>
<?php do { ?>
   <? $TotalScore = $row_get250Results['cookstown']   +
   $row_get250Results['tandragee']   +
   $row_get250Results['northwest']   +
   $row_get250Results['athea']       +
   $row_get250Results['skerries']    +
   $row_get250Results['southern']    +
   $row_get250Results['walderstown'] +
   $row_get250Results['kells']       +
   $row_get250Results['midantrim']   +
   $row_get250Results['ugp']         +
   $row_get250Results['killalane']   +
   $row_get250Results['scarborough']; 
   
   
while($row =  row_get250Results)
{
  $class = ($class == 'red') ? 'black' : 'red';
  //echo "<tr class = '$class'><tr>";
  echo "<tr class = '$class'>        
            <td ><p><?php echo $row_get250Results['f_name']; ?></p></td>
            <td ><p><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td align="center"><p><? echo $TotalScore?></p>
          </td>
          </tr> ";} ?> 
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
</table> <?php //} ?>
</td>
</tr>

</table>

Posted: Thu Jun 09, 2005 2:24 am
by Syranide
if you haven't noticed yet, the problem is (partially atleast) in "One" and "Two" which should be "_odd" and "_even"
EDIT: for the previous solution that was

Woo hoo! 800 posts

Posted: Thu Jun 09, 2005 9:39 am
by pickle
Remove the opening curly brace

Code: Select all

<?php while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
Also, I'd suggest looking into heredocs as opposed to always jumping in and out of PHP. It'll certainly make the code easier to debug.

Posted: Thu Jun 09, 2005 4:53 pm
by Addos
Thanks for your relentless help.
When I remove the curly brace I still get an error. “Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Inetpub\wwwroot\two_stroke\TMPx8qlihu7eg.php on line 100”
I’m just at a loss at this point so again any help is most welcome.
Thank you
Brian

Posted: Thu Jun 09, 2005 5:03 pm
by scorphus
Ok, let me help you.

I'm asking you to please post the most recent code, so I make sure we're talking about the same thing.

Thanks,
Scorphus.

Posted: Thu Jun 09, 2005 5:48 pm
by Addos
Hi scorphus,
Thanks you so much for you offer of help.
This is what I have been working on at present. I really have also tried your earlier offer of help you gave me in a earlier post but I just couldn’t get this to work either….sorry!

Code: Select all

mysql_select_db($database_blah, $blah);
$query_get250Results = " SELECT f_name, l_name, cookstown, tandragee, northwest, athea, skerries, southern, walderstown, kells, faugheen, midantrim, ugp, killalane, scarborough,
cookstown + tandragee+ northwest + athea + skerries+ southern+ walderstown + kells + faugheen + midantrim + ugp + killalane + scarborough
AS TotalScore
FROM 250_champion
ORDER BY TotalScore DESC";

<table width="100%" border="1">
  <tr>
  <td><h2>250 Championship</h2></td>
  </tr>
  <tr><td>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr align="center">
            <td><h1>Name</h1></td>
            <td><h1>&nbsp;</h1></td>
            <td><h1>Cookstown</h1></td>
            <td><h1>Tandragee</h1></td>
            <td><h1>NW200</h1></td>
            <td><h1>Athea</h1></td>
            <td><h1>Skerries</h1></td>
            <td><h1>Southern</h1></td>
            <td><h1>Walderstown</h1></td>
            <td><h1>Kells</h1></td>
            <td><h1>Faugheen</h1></td>
            <td><h1>Mid-Antrim</h1></td>
            <td><h1>UGP </h1></td>
            <td><h1>Killalane</h1></td>
            <td><h1>Scarborough</h1></td>
            <td><h1>Total</h1></td>
  </tr>
<?php   
   
while($row =  row_get250Results)
{
  $class = ($class == 'red') ? 'black' : 'red';
  //echo "<tr class = '$class'><tr>";
  echo "<tr class = '$class'>        
            <td ><p><?php echo $row_get250Results['f_name']; ?></p></td>
            <td ><p><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td align="center"><p><? echo $TotalScore?></p>
          </td>
          </tr> ";} ?> 
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
</table> 
</td>
</tr>
</table>
This (below) is what I originally started off with and produces this page http://www.ahamay.com/grid.htm exactly as I want just without the alternating colours applied to each row.

Code: Select all

<table width="100%" border="1">
  <tr>
  <td><h2>250 Championship</h2></td>
  </tr>
  <tr><td>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr align="center">
            <td><h1>Name</h1></td>
            <td><h1>&nbsp;</h1></td>
            <td><h1>Cookstown</h1></td>
            <td><h1>Tandragee</h1></td>
            <td><h1>NW200</h1></td>
            <td><h1>Athea</h1></td>
            <td><h1>Skerries</h1></td>
            <td><h1>Southern</h1></td>
            <td><h1>Walderstown</h1></td>
            <td><h1>Kells</h1></td>
            <td><h1>Faugheen</h1></td>
            <td><h1>Mid-Antrim</h1></td>
            <td><h1>UGP </h1></td>
            <td><h1>Killalane</h1></td>
            <td><h1>Scarborough</h1></td>
            <td><h1>Total</h1></td>
  </tr>
          <?php do { ?>
		    <tr>
            <td><p><?php echo $row_get250Results['f_name']; ?></p></td>
            <td><p><?php echo $row_get250Results['l_name']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['cookstown']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['tandragee']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['northwest']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['athea']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['skerries']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['southern']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['walderstown']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['kells']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['faugheen']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['midantrim']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['ugp']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['killalane']; ?></p></td>
            <td align="center" class="innerborder"><p><?php echo $row_get250Results['scarborough']; ?></p></td>
            <td align="center"><p><?php echo $row_get250Results['TotalScore']; ?></p>
            </td>
          </tr>
          <?php } while ($row_get250Results = mysql_fetch_assoc($get250Results)); ?>
</table>
</td>
</tr>
</table>
So as you can see all I want is to have each row in my table alternate with 2 different colours but for some reason this has been more than a challenge for me.

I really appreciate your offer of help thanks again
Brian