Table colours fail when extra row added
Posted on
16th Feb 2014 07:03 pm by
admin
Hey Gurus,
I got a weird problem with formating the colour of a table made in php. Everything works fine when i use 5 rows each row has an alturnative colour, but when i add the 6th row the colour fails and every row is the same colour which is the first colour (green). I used the same technique on every row so i dont understand how it fails with an extra row. Heres the code:
Line number On/Off | Expand/Contract $result = mysql_query("SELECT * FROM fulldata WHERE approved = '0'") or die(mysql_error() ); $i=1; $row = mysql_fetch_array($result); $line = mysql_fetch_assoc($result); // headers of the tableecho "<table width='100%' border='0' cellpadding='0' cellspacing='0'>"; echo "<tr><td align='left' width='40%'><b>Description</b></th><td align='center' width='30%'><b>Proof</b></th><td align='center' width='10%'><b>Workers Needed</b></th><td align='center' width='10%'><b>Price</b></th><td align='center' width='10%'><b>Accept</b></th><td align='center' width='10%'><b>Deney</b></th></tr>";// ITERATE OVER THE RESULTS SET while ($line = mysql_fetch_assoc($result)) {// GET EASY-TO-READ LOCAL VARIABLES foreach ($line as $key => $val) { $$key = htmlentities($val); }// CREATE THE ROW OF DATA $color = ($i % 2) ? "#3F6" : "#3CF"; echo "<tr>"; echo "<td style='background-color:$color' align='center'>$descript</td>n"; $i++; echo "<td style='background-color:$color' align='center'>$proof</td>n"; $i++; echo "<td style='background-color:$color' align='center'>$amountworkers</td>n"; $i++; echo "<td style='background-color:$color' align='center'>$perperson</td>n"; $i++; echo "<td style='background-color:$color' align='center'>Accept</td>n"; $i++; echo "<td style='background-color:$color' align='center'>Deney</td>n"; $i++; } // END WHILE ITERATOR echo "</table>n"; // END IF/ELSE ?>
that last row Quote: echo "<td style='background-color:$color' align='center'>Deney</td>n";
$i++; when added ruins all the colours. when taken out the table works fine
Your Answer:
Login to answer
284
13
Other forums
User registration and login
I don't know whether this is the correct forum, if not i apologise but am pretty desperate at the mo
Count of reciepients in php mailer
How can i sent a mail to large no of reciepients say 10,00,00 Using PHP MAILER
Hashing?
Hi, I was hoping to take a string value then convert it - consistently - across each of our pages in
how to get sn motherboard
Hello.
I want to get serial number motherboard, cpu and else hardware.
Can You show me sam
Edit MySQL Row Using PHP and HTML Form
Hello,
Here's what I'm trying to do. Build a page where a user enters a MySQL row number in.
Better Method of a Member Cloud
I assume most people know how tag clouds work, where the tags most used are bigger and the least use
HOW to get the bind variables list.
I've the following problem : I've some SQL queries stored in my DB as VARCHAR2 values.
I need t
mod_rewrite.c on windows ??
why it's not working on windows while it's working on other hosts???
this is the code i got
Is there a quick way to do this?
Hi all,
I need to create a mysql table from php that goes a little something like this
Coding Critique
I was hoping someone could take a second and look down my code and see if they see any problems with