unsider Posted July 9, 2008 Share Posted July 9, 2008 I need the <?=$row_blog['title'];?> posted in <?=$row_blog['category']?> by <?=$row_blog['name']; content to be alternated in the greycell, and whitecell divs, but for some reason I just can't logically write a piece of code that will accomplish this. <grey>content</grey> <white>content</white> Sorry about this, I'm just having trouble doing it. <div id="module-latest-threads"> <div class="module-header clear"></div> <div class="module-left-content clear"> <?php // SQL query $query="Select *,COUNT(*) FROM article INNER JOIN categories ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) GROUP BY title DESC LIMIT 3 "; $blog = mysql_query($query) or die(mysql_error()); $num_blog = mysql_num_rows($blog); if($num_blog > 0){ while($row_blog = mysql_fetch_assoc($blog)){ $row_blog['title']; posted in $row_blog['category'] by $row_blog['name']; ?> <table width="198"> <tbody><tr><td class="whitecell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="graycell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="whitecell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="graycell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="whitecell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="graycell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="whitecell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="graycell"> <div class="interviews"><a href="">test</a></div> </td></tr> <tr><td class="whitecell"> <div class="interviews"><a href="">test</a></div> </td></tr> </tbody></table> <?php } } else { echo "No topics to list"; } ?> </div> </div> <div class="module-separator"> </div> Quote Link to comment https://forums.phpfreaks.com/topic/113995-solved-displaying-content-within-while-loop/ Share on other sites More sharing options...
unsider Posted July 9, 2008 Author Share Posted July 9, 2008 I don't know what was wrong me. Need to lay off the old pipe. Sorry about that, figured it out. Quote Link to comment https://forums.phpfreaks.com/topic/113995-solved-displaying-content-within-while-loop/#findComment-585907 Share on other sites More sharing options...
ShimmyShine Posted July 9, 2008 Share Posted July 9, 2008 Here, Try this. <div id="module-latest-threads"> <div class="module-header clear"></div> <div class="module-left-content clear"> <?php $query="Select *,COUNT(*) FROM article INNER JOIN categories ON categoryID=catid WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) GROUP BY title DESC LIMIT 3 "; $blog = mysql_query($query) or die(mysql_error()); $num_blog = mysql_num_rows($blog); if($num_blog > 0){ echo "<table width=\"198\"><tbody>"; $i = 0; while($row_blog = mysql_fetch_assoc($blog)){ $i++; if($i % 2) { $b = "whitecell"; } else { $b = "graycell"; } echo "<tr><td class=\"".$b."\"><div class=\"interviews\"><a href=\"\">test</a></div></td></tr>"; } echo "</tbody></table>"; } else { echo "No topics to list"; } ?> </div> </div> <div class="module-separator"></div> Shimmy Quote Link to comment https://forums.phpfreaks.com/topic/113995-solved-displaying-content-within-while-loop/#findComment-585910 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.