<?php
include_once("config.php");
include_once("main_header.php");
$link = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die ("Could not connect");

@mysql_select_db(DB_NAME, $link);

?>
<center><h1>Blog List</h1></center>
<table width="100%" border="1" cellpadding="2" cellspacing="0">
<tr>
<td width="40%">Blog</td>
<td width="40%">User</td>
<td width="20%">Posts</td>
</tr>
<?php

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

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><a href=\"http://".$sitemainhost.$sitedomain."/".$username."/index.php\">$blogname</a></td>";
    echo "<td>$username</td>";
    echo "<td>$posts</td>";
    echo "</tr>";
  }
}
?>
</table>

<? include_once("main_footer.php"); ?>