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
Date help - fetch dates for Mondays between xxx and yyy?
Does anyone know the best way to do this? I have two dates, say:
2010-01-26 and 2010-05-30
How do I give a developer access to a specific directory and nothing else?
I want to give a develop access to a specific directory and nothing else
I can give them an F
Check something, wait, check again, do something!
Hi guys.
I wonder if someone can help me with this.
Basically, what I want to do is (
Php script to read msword file
hi,
I need to read a msword file and i want to print the contents in that word file.
i
Not capturing all the information we require in the form.......
Hi Guys,
I was wondering if you would share some more of your knowledge today, I'm hoping it
Grouping and sorting results
Please help with this query.
I have 2 tables in a database, countires and cities. states look
webpage with (simple) login & mysql-db
Hi all,
What I was looking for before was a multi-user password manager, web-based! The offer
quotes changing
hi all
in my content
opening quotes " changes to “
close qu
Help with search.php
Hello All
I need the search engine on a site I am building at the moment to display the searc
VAT
how should I deal with VAT?
if I have a product that costs £5.00 and VAT @ 17.5% (£0.87