PHP+MYSQL implementation of website online people statistics [code]_PHP tutorial

WBOY
Release: 2016-07-13 17:30:34
Original
941 people have browsed it

 php(as the current mainstream development language)Example tutorial: Program code for the number of people online on the website, with MySQL in the background (the best combination with PHP) Database support. Can directly count the number of people currently online on the website.

First, create the MySQL (the best combination with PHP) database table.

The following is a quotation fragment:
以下是引用片段:
CREATE TABLE tablename (
field type(max_length) DEFAULT default_value (NOT) NULL
}

CREATE TABLE tablename ( field type(max_length) DEFAULT default_value (NOT) NULL

}

以下是引用片段:
CREATE TABLE useronline (
timestamp int(15) DEFAULT 0 NOT NULL,
ip varchar(40) NOT NULL,
file varchar(100) NOT NULL,
Prima(最完善的虚拟主机管理系统)RY KEY (timestamp),
KEY ip (ip),
KEY file (file)
);
SQL statements that can be used
.
The following is a quote: CREATE TABLE useronline ( timestamp int(15) DEFAULT 0 NOT NULL, ip varchar(40) NOT NULL, file varchar(100) NOT NULL, Prima

(The most complete virtual host management system )

以下是引用片段:
$server = "localhost"; //你的服务器
$db_user = "root"; //你的MySQL(和PHP搭配之最佳组合)的用户名
$db_pass = "password"; //你的MySQL(和PHP搭配之最佳组合)的密码
$database = "users"; //表的名字
RY KEY (timestamp), KEY ip (ip),

KEY file (file)

);

以下是引用片段:
$timeoutseconds = 300;
Next we start using the php
(as the current mainstream development language) script, first define the information of MySQL

(the best combination with PHP)

以下是引用片段:
$timestamp = time();
.
The following is a quote: $server = " localhost"; //Your server$db_user = "root"; //Your MySQL(the best combination with PHP) username$db_pass = "password" ; //Your MySQL(the best combination with PHP) password$database = "users"; //The name of the table
Set the statistical time (how many seconds are online)
The following is a quote: $timeoutseconds = 300 ;
Get the current time.
The following is a quote: $timestamp = time ();

The complete code above:

The following is a quote:
以下是引用片段:
(做为现在的主流开发语言)
$server = "localhost"; //your server
$db_user = "root"; //your MySQL(和PHP搭配之最佳组合) database username
$db_pass = "password"; //your MySQL(和PHP搭配之最佳组合) database password if any
$database = "users"; //the db name
$timeoutseconds = 300;//timeoutseconds limit
//get the current time
$timestamp = time();
//calculate the lowest timestamp allowed
$timeout = $timestamp-$timeoutseconds;
?>

(as the current mainstream development language) $server = "localhost"; //your server $db_user = "root"; //your MySQL

(matched with PHP The best combination)

database username

以下是引用片段:
MySQL(和PHP搭配之最佳组合)_connect(localhost, username, password);
$db_pass = "password"; //your MySQL

(The best combination with PHP)

database password if any
$database = " users"; //the db name

以下是引用片段:
MySQL(和PHP搭配之最佳组合)_connect($server, $db_user, $db_pass);
$timeoutseconds = 300;//timeoutseconds limit

//get the current time

$timestamp = time(); //calculate the lowest timestamp allowed $timeout = $timestamp-$timeoutseconds;
?>

以下是引用片段:
MySQL(和PHP搭配之最佳组合)_connect($server, $db_user);
Connect to MySQL

(The best combination with PHP)

以下是引用片段:
MySQL(和PHP搭配之最佳组合)_db_query(database, query);
The following is a quote: MySQL (The best combination with PHP)_connect(localhost, username, password);
Variable forms are also allowed.
The following is a quote: MySQL (The best combination with PHP)_connect($server, $db_user, $db_pass);
If the MySQL (the best combination with PHP) database does not have a password, you can use the following code to connect (of course it is recommended that you set your own password, so at least the hacker has to decrypt it)
The following is a quote: MySQL (The best combination with PHP)_connect($server, $db_user);
Query database code:
The following is a quote: MySQL (The best combination with PHP)_db_query(database, query);

Whenever we have a visitor, we will add a record.

The following is a quotation fragment:
$insert = MySQL(The best combination with PHP)_db_query($

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509160.htmlTechArticlephp (as the current mainstream development language) Example tutorial: Program code for the number of people online on the website, with MySQL in the background ( The best combination with PHP) database support. You can directly count the website when...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!