<?php
include_once("config.php");

$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die ("Could not connect");

@mysql_select_db(DB_NAME, $link);

?>
<table width="100%" border="0" cellpadding="2" cellspacing="0"> 
<tr> <td width="80%"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">Blog Name</FONT></td><td width="20%"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2">Posts</FONT></td></tr> 
<?php

$r=mysql_query("select username,posts from blogusers order by posts desc LIMIT 5");

while (list($username,$posts)=mysql_fetch_row($r)) {
  $tablename = "wp_"."$username"."_options";
  $r1=@mysql_query("select option_value from $tablename where option_name='blogname' order by option_id desc",$link);
  if ($r1) {
    echo "<tr>";
    list($blogname)=@mysql_fetch_row($r1);
    echo "<td><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"2\"><a href=\"http://".$sitemainhost.$sitedomain."/".$username."/index.php\">$blogname</a></FONT></td>";
    echo "<td><FONT FACE=\"Arial, Helvetica, sans-serif\" SIZE=\"2\">$posts</FONT></td>";
    echo "</tr>";
  }
}
?> </table>
