This program has four counters.
Index. php is a common counter that shows the total number of times and the number of people who come to the site. It is not waterproof when you click a few times.
Index1.php is also a waterproof counter that shows the number of times and the number of people who come to the site. It is waterproof and can be added once every 5 seconds.
Index2.php is a waterproof counter that shows the total number of times and the number of people who come to the site. The number of times points is added several times, which is waterproof and can be added once in 2 seconds.
Indexa. php is a common, waterproof, and graphic counter in three-in-one. We can see the total number of times and the number of people who came to the site, which is waterproof and graphic.
Key statement:
Waterproof: $ SQL = "SELECT COUNT (*) FROM 'counter _ 1' WHERE user = '$ user' AND TIME_TO_SEC (NOW ()-'time ') <5 AND ip = '$ REMOTE_ADDR '";
Graphic counters: for ($ I = 0; $ I <strlen ($ row [0]); $ I ++)
{
$ Digit = substr ($ row [0], $ I, 1 );
$ Pic. = " ";
}
<?
// ------ [Basic settings] -------
$ Mysql_server_name = "localhost ";
$ Mysql_username = "root ";
$ Mysql_password = "512783 ";
$ Mysql_database = "jishuqi ";
//-------
// Prepare your SQL
$ SQL = "INSERT INTO 'counter _ 1' ('user', 'IP', 'time') VALUES ('$ user',' $ ip ', NOW ());";
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
Mysql_select_db ($ mysql_database, $ conn );
$ Result = mysql_query ($ SQL );
// $ Id = mysql_insert_id ();
Mysql_close ($ conn );
// Establish a connection ------ pass (server address, user name, user password)
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// Prepare your SQL syntax
$ SQL = "SELECT COUNT (*) FROM 'counter _ 1 '";
// Query (or execution, select)
$ Result = mysql_db_query ($ mysql_database, $ SQL, $ conn );
// Capture the query result -->
$ Row1 = mysql_fetch_row ($ result );
// Print the array of all columns of the data
// Print_r ($ row1 );
// Clear query results
Mysql_free_result ($ result );
// Establish a connection ------ pass (server address, user name, user password)
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password );
// Prepare your SQL syntax
$ SQL = "SELECT COUNT (*) FROM 'counter _ 1 'WHERE user =' $ user '";
// Query (or execution, select)
$ Result = mysql_db_query ($ mysql_database, $ SQL, $ conn );
// Capture the query result -->
$ Row2 = mysql_fetch_row ($ result );
// Print the array of all columns of the data
// Print_r ($ row2 );
// Clear query results
Mysql_free_result ($ result );
?>
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> three counters </title>
<Style type = "text/css">
<! --
. Style1 {
Font-size: 24px;
Color: #00FF99;
}
. Style2 {color: # FF00FF}
. Style3 {color: # CC0033}
. Style4 {color: # 0000FF}
. Style5 {color: # FF0000}
. Style6 {
Font-size: 36px;
Color: #996633;
}
-->
</Style>
</Head>
<Body>
<Div align = "center" class = "style1 style6"> under Maple Forest
</Div>
<Div align = "center">
<P class = "style1"> </p>
<P class = "style1"> </p>
<P class = "style1"> <span class = "style3"> total </span> <? = $ Row1 [0];?> <Span class = "style5"> People </span> <span class = "style4"> visited </span> <span class = "style2"> this website
</Span> </p>
<P class = "style1"> <span class = "style3"> total </span> <? = $ Row2 [0];?> <Span class = "style5"> People </span> <span class = "style4"> come </span> <span class = "style2"> <? = $ User?> Website
</Span>
</P>
</Div>
</Body>
</Html>