<!-- RIGHT SIDEBAR -->
<div id="right-menu">
	<center>
	
	<?php // PRINT OUT THE 250 x 300 code
	$query = "select * from adboxes where id=1;"; 
	$result = mysql_query($query,$connection) or die(mysql_error());
	$info = mysql_fetch_assoc($result);

	echo stripslashes($info['adcode']); 
	?>
	</center>
	<br />
	<?php 
	
	if ($_GET['id']) {
		echo "<h3>Most Viewed - ".$cattitle."</h3>";
		$catquery = "select * from categories where id =".$_GET['id'];
		$query = "select title, views, id from articles, articleviews where articleviews.articleid = articles.id and status=0 and (categoryid = ".$_GET['id']." OR parentid = ".$_GET['id'].") order by articleviews.views desc LIMIT 0, 8;";
				
	} else {
		echo "<h3>Most Viewed - All Categories</h3>";
		$catquery = "select * from categories";
		$query = "select title, views, id from articles, articleviews where articleviews.articleid = articles.id and status=0 order by articleviews.views desc LIMIT 0, 8;";
		}
	?>

		
	<div class="side-lists" style="width:245px;">
	<ul>
<?php
	
	$catresult = mysql_query($catquery,$connection) or die(mysql_error());
	$catinfo = mysql_fetch_array($catresult);
	$cattitle = $catinfo['name'];
			
	$articleresults = mysql_query($query,$connection) or die(mysql_error());
	$num_results = mysql_num_rows($articleresults);
	
	
if ($num_results == 0) { // Checks if category is empty
	echo "<p>No articles found</p>";
	
} else {

for ($i=0; $i <$num_results; $i++) { 
	$row = mysql_fetch_assoc($articleresults); 
	
//Get article info	
	$id = $row['id'];
	$title = $row['title'];
	if ($seourls == 1) {  $scrubtitle = generate_seo_link($title); }

// Display the article list
	if ($seourls == 1) { // With SEO URLS 
		echo "<li><a href=\"".$siteurl."/".$id."/".$scrubtitle."/\">".$title."</a></li>"; 
	} else {
		echo "<li><a href=\"".$siteurl."/article.php?id=".$id."\">".$title."</a></li>";
	}

}

}
?>
	</ul>
<br style="clear:left"/>
</div>

</div>

<div class="clear"></div>