The PHP source code as follows:
$mysql_host = "localhost";
$mysql_user = "root";
$mysql_pass = "";
$mysql_db = "wordpress";
$mysql_mylink = mysql_connect($mysql_host, $mysql_user, $mysql_pass)
or die ("Cannot make the connection");
mysql_select_db($mysql_db, $mysql_mylink)
or die ("Cannot connect to the database");
$strsql="select * from wp_blogs where blog_id>2 ";
$rs_query = mysql_query($strsql);
$alls=mysql_num_rows($rs_query);
while (($RS = mysql_fetch_array($rs_query))) {
extract($RS);
$blogid=$RS["blog_id"];
$query2 = "select * from wp_".$blogid."_posts ";
$result = mysql_query($query2);
$num= mysql_num_rows($result);
//print $num;
if ($num<=2) {
print "DROP TABLE IF EXISTS wp_".$blogid."_comments;";
print "DROP TABLE IF EXISTS wp_".$blogid."_links ;";
print "DROP TABLE IF EXISTS wp_".$blogid."_options ;";
print "DROP TABLE IF EXISTS wp_".$blogid."_postmeta ;";
print "DROP TABLE IF EXISTS wp_".$blogid."_posts ;";
print "DROP TABLE IF EXISTS wp_".$blogid."_terms ;";
print "DROP TABLE IF EXISTS wp_".$blogid."_term_relationships ;";
print "DROP TABLE IF EXISTS wp_".$blogid."_term_taxonomy ;";
print "DELETE from wp_blogs where blog_id=".$blogid.";";
}
}
mysql_close ();