allworknoplay Posted February 19, 2009 Share Posted February 19, 2009 Nope, the table and its contents load perfectly but the background colors are not there. :-\ Ok so everything is perfect now except for the rotating background colors? Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766236 Share on other sites More sharing options...
Lambneck Posted February 19, 2009 Author Share Posted February 19, 2009 well its basically back to square one now: trying to get the <tr> background colors to alternate. Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766249 Share on other sites More sharing options...
Lambneck Posted February 19, 2009 Author Share Posted February 19, 2009 right now the <tr>'s are echoed with this result: <tr class="0 % 2 ? 'even' : 'odd'"> Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766264 Share on other sites More sharing options...
allworknoplay Posted February 19, 2009 Share Posted February 19, 2009 right now the <tr>'s are echoed with this result: <tr class="0 % 2 ? 'even' : 'odd'"> Ok I get it, hold on i will give you the code. Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766269 Share on other sites More sharing options...
allworknoplay Posted February 19, 2009 Share Posted February 19, 2009 Hopefully this will work. <?php $result = mysql_query("SELECT submission_id, col_1, name, submission_date FROM $table WHERE topic_id = '0' ORDER BY submission_id DESC"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } $i = 0; while($row = mysql_fetch_array($result)) { $sql = "SELECT * FROM $table WHERE topic_id = " . $row['submission_id']; $comments = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); $count = mysql_num_rows($comments); $num = mysql_num_rows($result); if(($i%2) == 0 ) $class = 'EVEN' : $class = 'ODD'; echo '<tr class='".$class."' >'; echo '<td class="forumtd"><strong>'; echo '<a href="topic.php?id='.$row['submission_id'].'">'.stripslashes(htmlspecialchars($row['col_1'])).'</a>'; echo "</strong></td>"; echo '<td class="forumtd"><em>'; echo stripslashes(htmlspecialchars($row['name'])); echo "</em></td>"; echo '<td class="forumtd">'; echo $count; echo "</td>"; echo '<td class="forumtd">'; echo date("l M dS, Y", $row['submission_date']); echo "</td>"; echo "</tr>"; $i++; } mysql_free_result($result); ?> Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766271 Share on other sites More sharing options...
Lambneck Posted February 19, 2009 Author Share Posted February 19, 2009 :'( nope. now none of the echoed content shows up in the result. Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766284 Share on other sites More sharing options...
allworknoplay Posted February 19, 2009 Share Posted February 19, 2009 Ok well use this code: I wanted you to use the cleaner code but just use this so you can be on your way... <?php $result = mysql_query("SELECT submission_id, col_1, name, submission_date FROM $table WHERE topic_id = '0' ORDER BY submission_id DESC"); if (!$result) { die("Query to show fields from table failed:".mysql_error()); } $i = 0; while($row = mysql_fetch_array($result)) { $sql = "SELECT * FROM $table WHERE topic_id = " . $row['submission_id']; $comments = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); $count = mysql_num_rows($comments); $num = mysql_num_rows($result); if(($i%2) == 0 ) { $class = 'EVEN'; }else{ $class = 'ODD'; } echo '<tr class='".$class."' >'; echo '<td class="forumtd"><strong>'; echo '<a href="topic.php?id='.$row['submission_id'].'">'.stripslashes(htmlspecialchars($row['col_1'])).'</a>'; echo "</strong></td>"; echo '<td class="forumtd"><em>'; echo stripslashes(htmlspecialchars($row['name'])); echo "</em></td>"; echo '<td class="forumtd">'; echo $count; echo "</td>"; echo '<td class="forumtd">'; echo date("l M dS, Y", $row['submission_date']); echo "</td>"; echo "</tr>"; $i++; } mysql_free_result($result); ?> Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766300 Share on other sites More sharing options...
Lambneck Posted February 19, 2009 Author Share Posted February 19, 2009 Woohoo!! It works! thanks man, you really live up to your name! Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766310 Share on other sites More sharing options...
allworknoplay Posted February 19, 2009 Share Posted February 19, 2009 Woohoo!! It works! thanks man, you really live up to your name! No problem, I would have rather had you use the cleaner code but it's really no biggie... I just wanted to get you on your way so you're not stuck on this all day.... Link to comment https://forums.phpfreaks.com/topic/145770-solved-alternating-table-background-color/page/2/#findComment-766312 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.