Free Webmaster Resources .info
PHP Introduction and Tutorials Javascript  Introduction and Tutorials HTML  Introduction and Tutorials ASP  Introduction and Tutorials Free Internet Access Guide and Directory Webspace  Directory Webhosting  Directory Adult Webhosting  Directory PHP Hosting  Directory ASP Hosting  Directory
à Navigation
» Home
» Php Introduction
» Php Tutorials
» Submit Scripts
 
Subscribe for free!

Join our mailing list today and recieve free updates monthly with web hosting specials!
 
 

 

 

Free Webmaster Resources .info | Free PHP Tutorials


Log Stats in PHP

Now for the final part we will simply display the results of the stats table on the page . Here is the script , remember you will have to modify the username and password values to your own values. In this example we will show only 10 entries maximum , you can change this by altering or removing the LIMIT 10;

<?php
//make a connection
$connection = mysql_connect("localhost","username","password");
//select the database
mysql_select_db("stats" , $connection);
//create a sql query select all from stats table
$sql_query = "SELECT * FROM stats LIMIT 10";
//store query results in the $results variable
$results = mysql_query($sql_query);
//start our table
echo ("<table width ='100%' border ='1'>");
//this is simply the headings
echo ("<tr><th>id</th><th>browser</th><th>I.P address</th><th>Date of visit</th></tr>");
//loop through the rows
while ($tablerows = mysql_fetch_row($results))
{
echo("<tr>");
//this displays the ID field
echo("<td>$tablerows[0]</td>");
//this displays the browser field
echo("<td>$tablerows[1]</td>");
//this displays the ip field
echo("<td>$tablerows[2]</td>");
//this displays the logdate field
echo("<td>$tablerows[3]</td>");
echo("</tr>");
}
echo ("</table>");
?>

In a future tutorial we will add more stats , produce percentage shares for browsers , Operating Systems and also display daily hits , weekly hits , monthly hits and yearly hits.

[more][1] [2] [3]

Recommended Webhosting Company
Web Hosting
Find: Web hosting Review & Compare!

 

 
Related Websites
 


Free Email
Your source to free email.

Free Casino Downloads
Contains useful free casino downloads.

Free Software Downloads
A complete collection of free software downloads.

Free
Download free stuff from psike.com your free stuff resource.

Free Teen Online Dating
Meet other singles for free online dating.

Coolfreeweb.com
The Free category at coolfreeweb.com

My Directory Listing
A massive directory listing of websites

Website Collation Project
The website collation project contains a huge directory of websites.


 
Top Webhosts
 
 1. Web Hosting
 2. Free Web Hosting
 3. Hosting
 4. Free Web Hosting Info
 5. With Web Hosting
 
-
- Give us feedback
 
Last updated
Jan 03, 2009
Free Webmaster Resources .info | A resource must for every web master
Untitled Document - Web Hosting
- PHP Hosting
- Free Internet Access