RickChase Posted March 26, 2003 Share Posted March 26, 2003 I am using the code below to pull info from the db and display all albums released by this artist. Currently, it displays each release in a new <TD> which is great, but I would like to only show 5 <TD>\'s per row. If there are more than 5 releases, then create a new row for the next 5 and so on... I have been researching for 4 hours now and cannot figure it out. I have even looked at code from phpbb and oscommerce trying to get it and cannot. Any help is greatly appreciated. <? $color1 = "#151515"; $color2 = "#252525"; $row_count = 0; $db = mysql_connect("localhost", "", ""); mysql_select_db("relapse_releases",$db); $sql="SELECT * FROM entire_catalog WHERE artist=\'Amorphis\' ORDER BY release_date_us DESC"; $result=mysql_query($sql,$db); if(!mysql_num_rows($result)) { echo(" "); } else { $num = mysql_num_rows($result); $cur = 1; echo "<p><table border=0 cellpadding=2 cellspacing=0 width=80% class=table_border> <tr><td width=100%><table border=0 cellpadding=15 cellspacing=0 width=100% bgcolor=000000><tr>"; while ($num >= $cur) { $row = mysql_fetch_array($result); $artist = $row["artist"]; $title = $row["title"]; $release_date_us = $row["release_date_us"]; $catalog_number = $row["catalog_number"]; $cell_color = ($row_count % 2) ? $color1 : $color2; echo "<td valign=top width=125 bgcolor=$cell_color><center><a href="http://www.relapse.com/artists/".$catalog_number.".php"><img src="http://www.relapse.com/albumart/".$catalog_number."_85.gif" width=85 height=85 border=1><br><font class=artist><b>$artist</b></font><br><font class=title>"$title"</font></a></center></td>"; $cur++; $row_count++; } echo "</tr></table></td></tr></table>"; } ?> Thank you, Rick Quote Link to comment https://forums.phpfreaks.com/topic/271-limit-results-to-5-per-row/ Share on other sites More sharing options...
DocSeuss Posted March 30, 2003 Share Posted March 30, 2003 http://www.devshed.com/Server_Side/PHP/Pag...ting/page1.html that is the article you missed in your research. good luck!! Quote Link to comment https://forums.phpfreaks.com/topic/271-limit-results-to-5-per-row/#findComment-841 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.