<?php
session_start();
include("./functions.php");
include("./header.php");

$total_projects = mysql_result(mysql_query("select count(*) from autoposter_projects"),0);

$posted_projects = 0;
$pending_projects = 0;
$res = mysql_query("select * from autoposter_projects");
for($i=0; $i<mysql_num_rows($res); $i++) {
	$project_id = mysql_result($res, $i, "id");

	$chkstatus = mysql_result(mysql_query("select count(*) from autoposter_articles where posted='0' and project_id='$project_id'"),0);
    if($chkstatus == 0) {
    	$posted_projects += 1;
    } else {
    	$pending_projects += 1;
    }

}

$posted_articles = mysql_result(mysql_query("select count(*) from autoposter_articles where posted='1'"),0);
$pending_articles = mysql_result(mysql_query("select count(*) from autoposter_articles where posted='0'"),0);

echo "<table border=\"0\" width=\"100%\" id=\"settingstable\" cellspacing=\"0\" cellpadding=\"5\" bordercolor=\"#000000\" align=\"center\">
<tr><td colspan=\"2\" bgcolor=\"#C0C0C0\" align=\"center\">Overall Stats</td></tr>";
echo "</table>";

echo "<br /><br />Total Projects: <b>$total_projects</b><br /> Total Projects Pending: <b>$pending_projects</b> <br /> Total Projects Completed: <b>$posted_projects</b>";
echo "<br /> Total Published Articles: <b>$posted_articles</b> <br /> Total Pending Articles: <b>$pending_articles</b>";

include("./footer.php");
?>