Hiya I have a dynamic table and am trying to get the rows to be two different alternate colours. well Ive looked at a couple of snippets of this colour code and previous mails regarding this. Im having major troubles intergrating any of these suggestions with my code. Can anyone suggest where I am going wrong. Main problems are
1. where to put the loop for changing the colour (complicated due to the loop retrieving data from db)i.e in the do loop....in the while loop?


2. Also how to echo my rows in the colours.(something like this I think)
print "<tr bgcolor='$trcolor'>"$db_fetch['bugid']; ?></td>;


e.g here is the code snippet for alternate coloured rows $trcolor="#F0F8FF"; while ($myrow = mysql_fetch_array($result)){ $colorset=0; if ($trcolor=='#F0F8FF'){ $trcolor='#B0C4DE'; $colorset=1; } if ($colorset==0){ if ($trcolor=='#B0C4DE'){ $trcolor='#F0F8FF';} } print "<tr bgcolor='$trcolor'>"; }



I have included my table file. Any suggestions would be great (even further suggestions of code snippets I can look at)

thanx

here is my table.:
<?
require_once('db_api.php');


db_connect(); $querystring= "SELECT * FROM bug"; $db_result = mysql_query($querystring) or die(mysql_error()); $db_fetch = mysql_fetch_assoc($db_result); $db_totalrows = mysql_num_rows($db_result); //echo $db_totalrows; ?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p>&nbsp;</p>

<table  border="2" cellspacing="2" bgcolor="#FFFFFF">
 <tr>
   <td colspan="9" bgcolor="#9999FF">&nbsp;</td>
 </tr>

<tr>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">bugid</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">status</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">severity</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">summary</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">description</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">date_opened</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">estimation_completion</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">related_file</font></td>
<td bordercolor="#999999"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">created_by</font></td>
</tr>
<? do { ?>



<td><? echo $db_fetch['bugid']; ?></td> <td><? echo $db_fetch['status']; ?></td> <td><? echo $db_fetch['severity']; ?></td> <td><? echo $db_fetch['summary']; ?></td> <td><? echo $db_fetch['description']; ?></td> <td><? echo $db_fetch['date_opened']; ?></td> <td><? echo $db_fetch['estimated_completion']; ?></td> <td><? echo $db_fetch['related_file']; ?></td> <td><? echo $db_fetch['created_by']; ?></td>

  <tr>
        <?
         } while ($db_fetch = mysql_fetch_assoc($db_result));
         ?>
        <td colspan="9" bgcolor="#9999FF">&nbsp;</td>


</table>


<p>&nbsp;</p>
<p>&nbsp;</p>
</body>
</html>

<?
mysql_free_result($db_result);
?>




_________________________________________________________________
Overloaded with spam? With MSN 8, you can filter it out http://join.msn.com/?page=features/junkmail&pgmarket=en-gb&XAPID=32&DI=1059



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to