Hi,
I am pretty new to PHP and am developing a PHP script to show stats for how many users have signed up on my site, posted articles and comments.
The following code does what I need, but is very long-winded. I would really appreciate if anyone has suggestions on how to cut it down.
Code: Select all
<?php
//Required Functions
function intra_pageheaders(){
?>
<?php
}
function intra_pageContent(){
global $intra_moduleId,$cols,$tid;
$message="";
doOps();
$tid=1;
?>
<h1>Website User Statistics</h1>
<div id="box80">
<?php tablePass(); ?>
</div>
<?php
}
//Independant Functions
//Articles
function tablePass(){
global $intra_moduleId,$xdb_mod,$xdb,$table,$cols,$tid;
$num_nu_june2009 = GetNewUsersJune2009();
$num_nu_may2009 = GetNewUsersMay2009();
echo '<table width="100%" border="0" cellspacing="0px" cellpadding="2px">';
echo "<tr class='glow' style='font-weight:bold;'><td>Month</td><td>New Users</td><td>New Articles</td><td>New Comments</td></tr>";
echo "<tr class='glow'><td>June 2009</td><td>".$num_nu_june2009."</td><td></td><td></td></tr>";
echo "<tr class='glow'><td>May 2009</td><td>".$num_nu_may2009."</td><td></td><td></td></tr>";
echo "<tr class='glow'><td>April 2009</td><td></td><td></td><td></td></tr>";
echo "<tr class='glow'><td>March 2009</td><td></td><td></td><td></td></tr>";
echo "<tr class='glow'><td>February 2009</td><td></td><td></td><td></td></tr>";
echo "<tr class='glow'><td>January 2009</td><td></td><td></td><td></td></tr>";
echo '</table>';
}
function GetNewUsersJune2009() {
global $intra_moduleId,$xdb_mod,$table;
$sql_nu_june2009="SELECT * FROM `site_users` WHERE `joined` <= '2009-06-01 00:00:00' AND `joined` >= '2009-05-1 00:00:00'";
$new_users_june2009=@mysql_query($sql_nu_june2009);
$num_nu_june2009=mysql_numrows($new_users_june2009);
return $num_nu_june2009;
}
function GetNewUsersMay2009() {
$sql_nu_may2009="SELECT * FROM `site_users` WHERE `joined` <= '2009-05-01 00:00:00' AND `joined` >= '2009-04-1 00:00:00'";
$new_users_may2009=@mysql_query($sql_nu_may2009);
$num_nu_may2009=mysql_numrows($new_users_may2009);
return $num_nu_may2009;
}
?>
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: