<?
/*
--------------------------------------------------------------------------
| Musicbox Version 2.3.7
| ========================================
| by Shalwan
| (c) 2008 Shalwan Enterprises LLC
| http://www.shalwan.com
| ========================================
| Web:
http://www.musicboxv2.com | Email:
products@shalwan.com| Licence Info:
http://www.shalwan.com/license---------------------------------------------------------------------------
*/
@include("sources/session.php");
@include("sources/functions.php");
$sql="select * from config where id=3";
$rs=mysql_query($sql) or die(mysql_error());
$row=mysql_fetch_array($rs);
ob_start();
@include("template/header2.php");
define('ITEMS_PER_PAGE', 40);
function getTotalArtists()
{
$query = "select count(*) as 'total' from artist where 1";
$results = mysql_query($query);
$row = mysql_fetch_assoc($results);
return $row['total'];
}
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'];
}
$genre_id = $_GET['id'];
$items = ITEMS_PER_PAGE;
if(isset($_GET['page']))
{
$offset = $_GET['page'];
$offset *= $items;
$query = "select id, name, artist_photo from artist limit $offset,$items";
}
else
{
$query = "select id, name, artist_photo from artist";
}
$allArtists = mysql_query($query);
echo "<table class='moduletable' cellpadding = '0' cellspacing = '0'><tr><th>All Artists</th></tr></table>";
if(!allArtists)
{
echo 'There are no artists in database';
}
else
{
while($artist = mysql_fetch_assoc($allArtists))
{
$artistPhoto = $artist['artist_photo'];
$artistName = $artist['name'];
print("<table class ='albumbox'><tr><td><table class='albumbox2'><tr><td><a href='index.php?action=artist&id=".$artist['id']."'><img src='$artistPhoto' /></a></td>");
print("<td valign='top'>");
print("<b><a href='index.php?action=artist&id=".$artist['id']."'>$artistName</a></b><br />");
print("Total Albums: ".getAlbumCount($artist['id']).'<br />');
print("Total Songs: ".getSongCount($artist['id']).'<br />');
print("</td></tr></table></td></tr></table>");
}
}
mysql_free_result($allArtists);
$artistCount = getTotalArtists(); //mysql_num_rows($allArtists);
// Paginate
$numPages = floor($artistCount / ITEMS_PER_PAGE);
if($numPages > 0 )
{
print('<table class="moduletable" align="left"><tr><td><center>Pages[');
for($i = 0; $i < $numPages; $i++)
{
print("<a href='?id=$genre_id&page=$i'> ".($i+1).' </a>');
}
print(']</center></td></tr></table>');
}
include("template/header_bottom.php");
ob_end_flush();
?>