Location: PHPKode > scripts > Visitor Logger > charts.txt
<h1>Charts</h1>

<?php
if ($_POST['charts'] == 7) { $VL_days['msg'] = "Results for the last 7 days"; $VL_days['val'] = 7; }
elseif ($_POST['charts'] == 30) { $VL_days['msg'] = "Results for the last 30 days"; $VL_days['val'] = 30; }
elseif ($_POST['charts'] == 365) { $VL_days['msg'] = "Results for the last 365 days"; $VL_days['val'] = 365; }
else { $VL_days['msg'] = "Results for today and yesterday"; $VL_days['val'] = 1; }

echo "<form method=\"post\" action=\"".$VL_self."\">";
echo "<select name=\"charts\" onChange=\"this.form.submit()\">";
echo "<OPTION value=".$VL_days['val']." selected>".$VL_days['msg']."</OPTION>";
if ($VL_days['val'] != 1) echo "<OPTION value=\"1\">Results for today and yesterday</OPTION>";
if ($VL_days['val'] != 7) echo "<OPTION value=\"7\">Results for the last 7 days</OPTION>";
if ($VL_days['val'] != 30) echo "<OPTION value=\"30\">Results for the last 30 days</OPTION>";
if ($VL_days['val'] != 365) echo "<OPTION value=\"365\">Results for the last 365 days</OPTION>";
echo "</select><noscript><input type=\"submit\" value=\"Update\"></noscript></form>";


$VL_nowdate = getdate();
$VL_nowyear = $VL_nowdate['year'];
$VL_nowmonth = $VL_nowdate['mon'];
$VL_nowday = $VL_nowdate['mday'];

$VL_time = time();
$VL_time = $VL_time - ($VL_days['val'] * 86400);
$VL_thendate = getdate($VL_time);
$VL_thenyear = $VL_thendate['year'];
$VL_thenmonth = $VL_thendate['mon'];
$VL_thenday = $VL_thendate['mday'];

$VL_now = $VL_nowyear."-".$VL_nowmonth."-".$VL_nowday;
$VL_then = $VL_thenyear."-".$VL_thenmonth."-".$VL_thenday;

$VL_query = "select page,count(*) from ".$VL_table." where date between '".$VL_then."' and '".$VL_now."' group by page order by count(*) desc";
$VL_result = mysql_query($VL_query,$VL_conn);

$VL_bgcolour = "white";
?>
&nbsp;
<table width=100%><tr><td width=50% valign=top align=center>
<table border=0 bgcolor=#0000c2 style="color: white">
<tr>
<th width=30% align=center>Page</th>
<th width=10% align=center>Hits</th>
</tr>

<?php

while ($VL_row = mysql_fetch_array($VL_result, MYSQL_ASSOC)) {

	echo ("<tr bgcolor=\"".$VL_bgcolour."\" style=\"color: black\">");
	if ($VL_bgcolour == "white") $VL_bgcolour = "#e0ecff"; else $VL_bgcolour = "white";

	foreach ($VL_row as $VL_value) {
	echo ("<td align=center>".$VL_value."</td>");
	}

	echo ("</tr>");

}




$VL_query = "select ip,count(*) from ".$VL_table." where date between '".$VL_then."' and '".$VL_now."' group by ip order by count(*) desc";
$VL_result = mysql_query($VL_query,$VL_conn);

$VL_bgcolour = "white";
?>

</table></td><td width=50%  valign=top align=center>

<table width=30% border=0 bgcolor=#0000c2 style="color: white">
<tr>
<th width=40% align=center>IP Address</th>
<th width=25% align=center>Hits</th>
<th width=10% align=center>Info</th>
</tr>

<?php

while ($VL_row = mysql_fetch_array($VL_result, MYSQL_ASSOC)) {

	echo ("<tr bgcolor=\"".$VL_bgcolour."\" style=\"color: black\">");
	if ($VL_bgcolour == "white") $VL_bgcolour = "#e0ecff"; else $VL_bgcolour = "white";

	foreach ($VL_row as $VL_value) {
	echo ("<td align=center>".$VL_value."</td>");
	}
	echo ("<form method=\"post\" action=\"".$VL_self."\"><input name=\"ip\" type=\"hidden\" value=\"".$VL_row['ip']."\"><td align=center><input type=\"submit\" value=\"Go\" Title=\"See the table for IP address ".$VL_row['ip']."\"></td></form>");
	echo ("</tr>");

}


?>


</table></td></tr></table>
Return current item: Visitor Logger