Jump to content

Limit results to 5 per row


RickChase

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.