[SOLVED] Zebra Tables Help

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
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

[SOLVED] Zebra Tables Help

Post by C_Calav »

hi guys,

i have been following this tutorial http://www.linuxguruz.com/z.php?id=321

and it looks pretty simple. i have done some things differently, and i cant get any colour displaying. not getting any errors.

can anyone takre a look and see what im doing wrong please? any help would be great!

thanx!

Code: Select all

<?php
  $db = mysql_pconnect('xxxx', 'xxxx', 'xxxx') or die ("Could not connect to database");


  mysql_select_db('models') or die ("Could not select database!"); 

  $query = "select * from planes";
  $result = mysql_query($query);

  $num_results = mysql_num_rows($result);


  echo '<p>Number of Planes found: '.$num_results.'</p>';

  echo "<table>

  	<tr> <td> <B> Stock # </td>
  	<td> <B> Name </td>
  	<td> <B> Category </td>
  	<td> <B> Scale </td>
  	<td> <B> Length </td>
  	<td> <B> Span </td>
  	<td> <B> Price </td>
        <td> <B> Description </td> </tr>";

  for ($i=0; $i <$num_results; $i++)
  {

     if(($i % 2) == 0) { $c = "#9999CC"; } 
     else { $c = "#CCCCCC"; }
	

     $row = mysql_fetch_array($result);
     
     $P_Stock = $row['P_Stock'];
     $P_Name = $row['P_Name'];
     $P_Cat = $row['P_Cat'];
     $P_Scale = $row['P_Scale'];
     $P_Length = $row['P_Length'];
     $P_Span = $row['P_Span'];
     $P_Price = $row['P_Price'];
     $P_Desc = $row['P_Desc'];

    
     echo "<tr><td bgcolor=$c> $P_Stock </a>  </td>
     	   <td>$P_Name</td>
     	   <td> $P_Cat </td>
     	   <td> $P_Scale </td>
     	   <td> $P_Length </td>
     	   <td> $P_Span </td>
     	   <td> $P_Price </td>
     	   <td> $P_Desc </td> </tr> ";
   
  }

    echo"  </table>";
?>
User avatar
C_Calav
Forum Contributor
Posts: 395
Joined: Wed Jun 02, 2004 10:55 pm
Location: New Zealand

Post by C_Calav »

i got it going now i had the CSS sytle sheet overlapping the color duh!
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

excellent! glad to see you worked things out :P
Post Reply