<?php
include('header.php');
if ( isset($_GET['id']) )
{
$id = intval($_GET['id']);
}
else
{
$id = '';
}
if ( empty($id) )
{
content_box('<hr /><b style="color: red">No Country ID specified.</b><hr /><br />');
}
// ----------------------------------------------------------------
// Query Database for Country Data
// ----------------------------------------------------------------
$sql = "SELECT *
FROM " . COUNTRY_TABLE . "
WHERE Country_ID = $id";
if ( !($result = $db->sql_query($sql)) )
{
content_box('<hr /><b style="color: red">Could not execute database query #1.</b><br /><br />' . $sql . '<hr /><br />');
}
while ($row = $db->sql_fetchrow($result))
{
$countryhighlights = $countryartists = $countrylabels = '';
$percentage = $total = $artists = $labels = 0;
// ----------------------------------------------------------------
// Query Database for Artist/Group Highlights
// ----------------------------------------------------------------
$sql2 = "SELECT Artist_ID, ArtistName, ArtistPicture
FROM " . ARTIST_TABLE . "
WHERE Country_ID = $id
AND ArtistPicture != ''
ORDER BY RAND()
LIMIT 0, 5";
if ( !($result2 = $db->sql_query($sql2)) )
{
content_box('<hr /><b style="color: red">Could not execute database query #2.</b><br /><br />' . $sql2 . '<hr /><br />');
}
while ($row2 = $db->sql_fetchrow($result2))
{
// ----------------------------------------------------------------
// Artist/Group Highlights
// ----------------------------------------------------------------
$picture = (!empty($row2['ArtistPicture'])) ? 'thumb.php?u=' . $row2['Artist_ID'] . '&p=1' : 'style/' . $style . '/no-artist.gif';
$artist = '';
$artist .= (!empty($row2['Artist_ID'])) ? '<a href="artist.php?id=' . $row2['Artist_ID'] . '">' : '';
$artist .= '<img src="' . $picture . '" title="' . $row2['ArtistName'] . '" alt="' . $row2['ArtistName'] . '" width="128" height="128" class="picture" /><br />' . $row2['ArtistName'];
$artist .= (!empty($row2['Artist_ID'])) ? '</a>' : '';
$countryhighlights .= '<td valign="top" align="center" width="128">' . $artist . '</td>';
}
$db->sql_freeresult($result2);
// ----------------------------------------------------------------
// Query Database for Artists/Groups from this country
// ----------------------------------------------------------------
$sql3 = "SELECT Artist_ID, ArtistName
FROM " . ARTIST_TABLE . "
WHERE Country_ID = $id
GROUP BY Artist_ID
ORDER BY ArtistName";
if ( !($result3 = $db->sql_query($sql3)) )
{
content_box('<hr /><b style="color: red">Could not execute database query #3.</b><br /><br />' . $sql3 . '<hr /><br />');
}
while ($row3 = $db->sql_fetchrow($result3))
{
// ----------------------------------------------------------------
// Artists/Groups from this country
// ----------------------------------------------------------------
$artist = (!empty($row3['Artist_ID'])) ? '<a href="artist.php?id=' . $row3['Artist_ID'] . '">' . $row3['ArtistName'] . '</a>' : $row3['ArtistName'];
$countryartists .= $artist . '<br />';
$artists++;
}
$db->sql_freeresult($result3);
// ----------------------------------------------------------------
// Query Database for Publishers from this country
// ----------------------------------------------------------------
$sql4 = "SELECT Label_ID, LabelName
FROM " . LABEL_TABLE . "
WHERE Country_ID = $id
ORDER BY LabelName";
if ( !($result4 = $db->sql_query($sql4)) )
{
content_box('<hr /><b style="color: red">Could not execute database query #4.</b><br /><br />' . $sql4 . '<hr /><br />');
}
while ($row4 = $db->sql_fetchrow($result4))
{
// ----------------------------------------------------------------
// Publishers from this country
// ----------------------------------------------------------------
$label = (!empty($row4['Label_ID'])) ? '<a href="label.php?id=' . $row4['Label_ID'] . '">' . $row4['LabelName'] . '</a>' : $row4['LabelName'];
$countrylabels .= $label . '<br />';
$labels++;
}
$db->sql_freeresult($result4);
// ----------------------------------------------------------------
// Country Data
// ----------------------------------------------------------------
$percentage = $artists + $labels;
$total = get_helium_stat('total_artists') + get_helium_stat('total_labels');
$pagetitle = $row['CountryName'];
$content = '<table cellpadding="3" cellspacing="1" class="borderstat" width="100%">
<tr>
<td>' . ((file_exists('img/flags/' . strtolower(str_replace(' ', '', $pagetitle)) . '.gif')) ? '<img src="img/flags/' . strtolower(str_replace(' ', '', $pagetitle)) . '.gif" alt="' . $pagetitle . '" title="' . $pagetitle . '" width="32" height="20" />' : ' ') . '</td>
<td width="97%" valign="middle">Percentage of total: ' . sprintf("%.1f", ($percentage / $total) * 100) . '%</td>
</tr>
<tr>
<td colspan="2" class="smallfont">
' . ((!empty($countryhighlights)) ? '<h3>Artist/Group Highlights</h3><table cellpadding="2" cellspacing="1"><tr>' . $countryhighlights . '</tr></table><hr />' : '') .
((!empty($countryartists)) ? '<h3>Artists/Groups from this country (' . $artists . ' in total)</h3>' . $countryartists . '<hr />' : '') .
((!empty($countrylabels)) ? '<h3>Labels from this country (' . $labels . ' in total)</h3>' . $countrylabels . '<hr />' : '') . '
</td>
</tr>
</table>
<br />';
}
$db->sql_freeresult($result);
headerstat($pagetitle);
echo $content;
include('footer.php'); ?>