p9j Posted June 21, 2011 Share Posted June 21, 2011 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:) Quote Link to comment https://forums.phpfreaks.com/topic/239971-need-help-with-music-categories/ Share on other sites More sharing options...
p9j Posted June 21, 2011 Author Share Posted June 21, 2011 and thats 20 newest albums code in index.php /** * Only list 20 newest albums if this is the homepage */ if (!$HTTP_GET_VARS) $query = "SELECT TO_DAYS(now())-TO_DAYS(album.post_date)as date_diff, album.album_name, artist.name as artist_name, album.album_photo, album.album_info, album.id as album_id, artist.id as artist_id,album.post_date FROM album, artist WHERE album.artist_id = artist.id ORDER BY album.id DESC LIMIT 20"; else $query = "SELECT TO_DAYS(now())-TO_DAYS(album.post_date)as date_diff, album.album_name, artist.name as artist_name, album.album_photo, album.album_info, album.id as album_id, artist.id as artist_id FROM album, artist WHERE album.artist_id = artist.id ORDER BY album.id DESC LIMIT 20"; $result = mysql_query($query) or die(mysql_error()); print("<td valign='top' class='album_bg' style='border-top: 0px solid #FFFFFF;'> <table cellpadding='0' cellspacing='0' class='moduletable'> <tr> <td valign='top' class=title_class align=left> ".$lang['20_Newest_Albums']." </td> </tr></table>"); print("<title>".PGTITLE."</title>"); print("<table cellpadding=2 cellspacing=2 width=100%> <tr><td> \n"); $lastchar = ''; while( $album = mysql_fetch_assoc($result) ) { // get initial name character if( $sortby == 'album' ) { $thischar = $album['album_name']{0}; $display = $album['album_name']." - ".$album['artist_name']; } else { $thischar = $album['artist_name']{0}; $display = $album['album_name']; } // Check to see if different than last if( $lastchar != $thischar ) { if( $lastchar != '' ) { print(""); } } // Print album Info //echo "<br/>album['album_photo'] urldecode : ".urldecode($album['album_photo']); //echo "<br/>album['album_photo'] : ".$album['album_photo']; $query = 'select count(*) as total from song where song.album_id = '.$album['album_id']; $totalSongs = mysql_query($query); $totalSongs = mysql_fetch_assoc($totalSongs); $totalSongs = $totalSongs['total']; [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/239971-need-help-with-music-categories/#findComment-1232670 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.