Jump to content


Photo

Limit results to 5 per row


  • Please log in to reply
1 reply to this topic

#1 RickChase

RickChase
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 26 March 2003 - 06:07 PM

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

#2 DocSeuss

DocSeuss
  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts
  • LocationTexas, USA

Posted 30 March 2003 - 06:01 AM

http://www.devshed.c...ting/page1.html


that is the article you missed in your research.


good luck!!
"Unlimited budget? Great, for $5,000,0000 we will run your ad banner for one year"  ----Rasmus Lerdorf




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users