hey evry1 whtz up??
i need help with this..i have this website: livepunjabi.com/music and on home page underneath 20 Newest albums i want show 10 albums from each Genre (category) example: livepunjabi.com/music/index.php?action=genre&id=2
same thing with other genres.
here is the index page code:
/********** Genre Functions **********/
function genre() {
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$genre = $HTTP_GET_VARS['id'];
if( $genre != '' ) {
$this->displayGenre($genre);
} else {
$this->listGenres();
}
}
function displayGenre( $id )
{
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$sortby = $HTTP_POST_VARS['sort'];
if( $id == 'all' ) {
$query = "SELECT * FROM genre WHERE 1";
} else {
$query = "SELECT * FROM genre WHERE id = '".$id."'";
}
$result = mysql_query($query);
$genre = mysql_fetch_assoc($result);
//$query = "SELECT TO_DAYS(now())-TO_DAYS(album.post_date)as date_diff, album.id as album_id, album.album_name, album.album_photo, artist.name as artist_name FROM album, artist WHERE ".(($id!='all')?"album.genre_id = '".$id."' AND ":"")."album.artist_id = artist.id ORDER BY ".(($sortby=='album')?'album.album_name':'artist.name')." ASC";
$query = 'select * from artist where genre_id = '.mysql_real_escape_string($id).' ORDER BY artist.name ASC';
$result = mysql_query($query) or die(mysql_error());
// Genre
print("<title>".$genre['genre']."</title>");
print("<META name='description' content='".$genre['genre']."'>
<META name='distribution' content='global'>
<META NAME='ROBOTS' CONTENT='index,follow'>
<META NAME='REVISIT-AFTER' CONTENT='3 days'>
<META name='keywords' content='".$genre['genre']."'>");
print("<table cellpadding='0' cellspacing='0' class='moduletable'>
<tr>
<td class='title_class' valign='top'>".$genre['genre']." </td>
</tr></table> \n");
print("<div id='content' class=content>");
$lastchar = '';
while( $album = mysql_fetch_assoc($result) )
{
$artistName = $album['name'];
if (is_file($album['artist_photo']))
{
$artistPhoto = $album['artist_photo'];
}
else
{
$artistPhoto = "images/notavailable.gif";
}
$song_ids = $this->getArtistSongs($album['id']);
print("<div id='content' class=content><table class ='albumbox'><tr><td><table ><tr><td><table ><tr><td><div id='newartframe'><div id='newartfr'><a href='index.php?action=artist&id=".$album['id']."'><img src='$artistPhoto' width=86 height=86/></a><br><br>");
print("<b><a href='index.php?action=artist&id=".$album['id']."'>$artistName</a></b><br />");
print("Total Albums: ".$this->getAlbumCount($album['id']).'<br />');
print("Total Songs: ".$this->getSongCount($album['id']).'<br />');
print('<a href=javascript:playMultiple("'.$song_ids.'");>Listen All</a>');
print("</div></div></td></tr></table></td></tr></table></td></tr></table>");
}
}
function getAlbumCount($artistId)
{
$query = "select count(*) as 'total' from album where artist_id = '$artistId'";
$results = mysql_query($query);
$row = mysql_fetch_assoc($results);
return $row['total'];
}
function getSongCount($artistId)
{
$query = "select count(*) as 'total' from song where artist_id = '$artistId'";
$results = mysql_query($query);
$row = mysql_fetch_assoc($results);
return $row['total'];
}
function getAlbumSongCount($albumId)
{
$query = "select count(*) as 'total' from song where album_id = '$albumId'";
$results = mysql_query($query);
$row = mysql_fetch_assoc($results);
return $row['total'];
}
function listGenres() {
global $HTTP_POST_VARS,$HTTP_GET_VARS,$HTTP_SERVER_VARS,$HTTP_SESSION_VARS,$HTTP_COOKIE_VARS,$HTTP_POST_FILES;
$query = "SELECT * FROM genre";
$result = mysql_query($query);
print("<div id='content' class=content>");
while( $genre = mysql_fetch_assoc($result) )
{
print("<a href='".$this->thisfile."?action=genre&id=".$genre['id']."'>".$genre['genre']."</a><br>");
}
print("</div>");
}
thanks in advance:)