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
284
13
Other php-forum
form submit at godaddy?
Trying to test form submission at GoDaddy and it does not seem to work. Here's the page...
h
some query on multilingual website
Hi all,
Which is the simplest and easiest method to make a website multilingual,
is it put
Word Trimming
Hi Guys & Gals!!
Hope you are all ok....
I need some help with the following
php mysql script to find record
Hi,
Currently I have a simple table with 4 columns. A, B, C, D
If I want to find all
Progress bar tracking file downloads
Hey guys, was wondering if there was a way to track how far a file has been downloaded. I know there
How can use this array as a key?
Say I have this array for example:
print_r($array);
Prints:
Code: [Select]Array
Echo-ing MySQL content and Keep Formatting?
I have data in my MySQL such as:
QuoteBlah blah
Blah blah
etc
but when i ech
BB_Code error
I'm having a problem with a custom built function and keep getting this error:
Warning: M
Help pulling in 'id' with "read more" link
I'm trying to create snippets of my articles in the cms I'm creating, and then have them redirect to
Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.
If i send the value by this