ra2833 Posted January 19, 2007 Share Posted January 19, 2007 i gather information from previous threads, but i can't seem to find out what my problem is in regards to this piece of code. can someone shed some light please?[code] <table width="480" border="0" cellpadding="0" cellspacing="0"> <tr class="darktable"> <td><strong>FAQ ID</strong></td> <td><a href="sort.by.crm.case.num.php" >CRM Case #</a> </td> <td><a href="sort.by.question.php">Question</a></td> <td><a href="sort.by.answer.php">Answer</a></td> <td><a href="sort.by.tech.php">Technician</a></td> <td><a href="sort.by.site.type.php">Site Type</a></td> <td><a href="sort.by.client_os.php">Client OS</a></td> <td><a href="sort.by.answer.php">Application</a></td> </tr> <?php $style = " "; ?> <?php $rowcolor1 = "#F0F0F2"; ?> <?php $rowcolor2 = "#FFFFFF"; ?> <?php $alternatecolorcounter = 0; ?> <?php do { ?> <?php if ($alternatecolorcounter % 2 == 1) { $style = $rowcolor1; } else { $style = $rowcolor2; } ?> <tr> <td style="background:'.$style.'"><?php echo $row_faq_all['faq_unique_id']; ?></td? </tr> <?php $alternatecolorcounter++ ?> <?php } while ($row_faq_all = mysql_fetch_assoc($faq_all) && $alternatecolorcounter <= $totalRows_faq_all); ?> </table>[/code] Link to comment https://forums.phpfreaks.com/topic/34821-php-and-mysql-alternate-row-color/ Share on other sites More sharing options...
kevinkorb Posted January 19, 2007 Share Posted January 19, 2007 Your problem is here<td style="background:'.$style.'">change to<td style="background:<?php echo $style;?>"> Link to comment https://forums.phpfreaks.com/topic/34821-php-and-mysql-alternate-row-color/#findComment-164139 Share on other sites More sharing options...
ra2833 Posted January 19, 2007 Author Share Posted January 19, 2007 thanks man, that was soooo freaking quick (awesome)....here is what i ended up with[code]<?php $style = ""; $rowcolor1 = "#8A3324"; $rowcolor2 = "#00B2EE"; $alternatecolorcounter = 0; do { if ($alternatecolorcounter % 2 == 1) { $style = $rowcolor1; } else { $style = $rowcolor2; } echo "\t<tr bgcolor=\"$style\">\n". "\t\t<td>". $row_faq_all['faq_unique_id'] ."</td>\n". "\t\t<td>". $row_faq_all['crm_case_num'] ."</td>\n". "\t\t<td>". $row_faq_all['question'] ."</td>\n". "\t\t<td>". $row_faq_all['answer'] ."</td>\n". "\t\t<td>". $row_faq_all['tech'] ."</td>\n". "\t\t<td>". $row_faq_all['site_type'] ."</td>\n". "\t\t<td>". $row_faq_all['client_os'] ."</td>\n". "\t\t<td>". $row_faq_all['application'] ."</td>\n". "\t</tr>\n"; $alternatecolorcounter++; } while ($row_faq_all = mysql_fetch_assoc($faq_all));?>[/code] Link to comment https://forums.phpfreaks.com/topic/34821-php-and-mysql-alternate-row-color/#findComment-164168 Share on other sites More sharing options...
whitelion Posted January 19, 2007 Share Posted January 19, 2007 you using this code to change your color row.That cool. Link to comment https://forums.phpfreaks.com/topic/34821-php-and-mysql-alternate-row-color/#findComment-164176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.