欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

php統(tǒng)計用戶數(shù)據(jù),php訪客統(tǒng)計

php怎么統(tǒng)計mysql表里有多少數(shù)據(jù),怎么把比如user里面的數(shù)據(jù)全部顯示出來

$conn

為城固等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及城固網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為成都網(wǎng)站建設(shè)、網(wǎng)站制作、城固網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!

=

mysql_connect('localhost','root','123');

mysql_select_db('db_name');

//數(shù)據(jù)庫名

mysql_query('set

names

utf8',$conn);

#$res

=

mysql_query('select

count(*)

from

user',$conn);

//統(tǒng)計user表里總共有多少條數(shù)據(jù)

#$res

=

mysql_query('select

*

from

user',$conn);

//把user里面的數(shù)據(jù)全部顯示出來

$arr

=

array();

while($data

=

mysql_fetch_assoc($res))

{

$arr[]

=

$data;

}

print_r($arr);

可以依次把上面查詢語句前面的注釋去掉查看效果

php如何利用session和mysql數(shù)據(jù)庫來統(tǒng)計用戶在線時常

您好,很高興回答您的問題,希望我的回答能幫助到您,蟹蟹

用戶在線時長計算,首先,用戶登錄成功把登錄時間以及用戶id保存在session中

當用戶退出時,當前時間減去登錄時間就是用戶在線時長

//用戶登錄

public?function?dologin(){

$adminname?=?I("param.adminname","","trim");//用戶名

$password?=?I("param.password","","trim");//密碼

$where?=?"adminname?=?'{$adminname}'?and?password?=?md5('{$password}')";

$data['login_time']?=?time();

$is_find?=?M("users_admin")-where($where)-find();

if($is_find){

$result?=?M("users_admin")-where($where)-setField($data);

if?($result){

$_SESSION['uid']?=?$is_find['id'];

$_SESSION['login_time']?=?$data['login_time'];

echo("登錄成功");

}

}????

}

//用戶退出代碼

public?function?logout(){

$login_time?=?$_SESSION['login_time'];

$now?=?time();

$line_time?=?$now-$login_time;

$result?=?M("users_admin")-where("id?=?".$_SESSION['uid'])-setField('line_time',$line_time);

session(null);

echo("成功退出");

}

PHP 在線人數(shù)統(tǒng)計 我的想法:建一個在線用戶數(shù)據(jù)表。

“用戶退出或者關(guān)閉瀏覽器SESSION消失的時候在線用戶表刪除相對應(yīng)的數(shù)據(jù)”

這里不可行。。服務(wù)器沒辦法獲取這個信息的。都是被動請求的。

要換個思路,要用js或者其它方式定時觸發(fā)刪除。。

一般15分鐘或者30分鐘。。

數(shù)據(jù)庫還要記錄IP,記錄最近一次觸發(fā)時間。

PHP如何統(tǒng)計在線人數(shù)

原理:根據(jù)不同的IP統(tǒng)計出當前有多少人在線。

實現(xiàn)方式:可以用數(shù)據(jù)庫,也可以用文本。

我這里用了文本實現(xiàn)。

$user_online?=?"count.php";?//?保存人數(shù)的文件

touch?(?$user_online?);?//?如果沒有此文件,則創(chuàng)建

$timeout?=?30;?//?30秒內(nèi)沒動作者,認為掉線

$user_arr?=?file_get_contents?(?$user_online?);

$user_arr?=?explode?(?'#',?rtrim?(?$user_arr,?'#'?)?);

print_r?(?$user_arr?);

$temp?=?array?();

foreach?(?$user_arr?as?$value?)?{

$user?=?explode?(?",",?trim?(?$value?)?);

if?(($user?[0]?!=?getenv?(?'REMOTE_ADDR'?))??($user?[1]??time?()))?{?//?如果不是本用戶IP并時間沒有超時則放入到數(shù)組中

array_push?(?$temp,?$user?[0]?.?","?.?$user?[1]?);

}

}

array_push?(?$temp,?getenv?(?'REMOTE_ADDR'?)?.?","?.?(time?()?+?($timeout))?.?'#'?);?//?保存本用戶的信息

$user_arr?=?implode?(?"#",?$temp?);

//?寫入文件

$fp?=?fopen?(?$user_online,?"w"?);

flock?(?$fp,?LOCK_EX?);?//?flock()?不能在NFS以及其他的一些網(wǎng)絡(luò)文件系統(tǒng)中正常工作

fputs?(?$fp,?$user_arr?);

flock?(?$fp,?LOCK_UN?);

fclose?(?$fp?);

echo?"當前有"?.?count?(?$temp?)?.?"人在線";

PHP如何實現(xiàn)統(tǒng)計用戶廣告點擊

先來創(chuàng)建數(shù)據(jù)庫.

CREATE TABLE IF NOT EXISTS `ad_count` (

`ad_id` int(8) NOT NULL auto_increment,

`ad_hit` int(8) NOT NULL default '0',

`ad_name` varchar(200) character set gb2312 default NULL,

`ad_datetime` datetime default NULL,

`ad_qq` varchar(15) character set gb2312 default NULL,

`ad_url` varchar(900) character set gb2312 NOT NULL,

`ad_price` int(8) NOT NULL,

PRIMARY KEY (`ad_id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

數(shù)據(jù)創(chuàng)建好了我們就開始寫程序了.數(shù)據(jù)連接我不不寫了,

?php

require_once("......省了");

$ad_id =get_value('ad_id','');這里下面有講

if(is_numeric( $ad_id ) ){

$ad_select="select ad_id,ad_url from ad_count where ad_id='$ad_id' limit 1";

$ad_update="Update ad_count set ad_hit=ad_hit+1 where ad_id='$ad_id' limit 1";

$ad_result=mysql_query($ad_select) or die('id error');

if( mysql_num_rows( $ad_result) ){

mysql_query($ad_update);

$ad_rs=mysql_fetch_array($ad_result);

header("location:".$ad_rs['ad_url']);

mysql_free_result($ad_rs);

}

}

function htmltohtml($Str){

$temp =str_replace(chr(13),'br/',$Str);

$temp =str_replace('','',$Str);

$temp =str_replace('','',$Str);

$temp =addslashes($Str);

return $temp;

}

function get_value($value,$para){

return htmltohtml(empty($para)?(isset($_GET[$value])?$_GET[$value]:''):(isset($_POST[$value])?$_POST[$value]:''));

}

然后我們再在要顯示廣告的地方如下寫.

'a href=/cp/ad_count.php?ad_id=2 target=_blankimg src=/ad_a/ad2.gif border=0 //a

php如何設(shè)計或?qū)崿F(xiàn)數(shù)據(jù)統(tǒng)計

統(tǒng)計,就是把基本的數(shù)據(jù),整合起來。

用到sql的,有g(shù)roup by 功能,count功能,order by功能等等。

sql將收集的數(shù)據(jù),進行統(tǒng)計分析。

一般情況下,sql處理后得到的數(shù)據(jù),還要通過php的邏輯來進行整理。

以一定的格式,展示到前臺。

一般都是以數(shù)組的方式展示,這也是數(shù)據(jù)結(jié)構(gòu)的概念。

看這張圖片,基本想想結(jié)構(gòu)大概為

{上線數(shù),出單總數(shù),核過總數(shù),總?cè)司偤寺剩瑊(坐席人1,工號1,出單數(shù)1,發(fā)貨數(shù)1,核單率1),(坐席人2,工號2,出單數(shù)2,發(fā)貨數(shù)2,核單率2)}}

如果用php展示成上面的結(jié)構(gòu)的話,就很好處理了。

分享標題:php統(tǒng)計用戶數(shù)據(jù),php訪客統(tǒng)計
URL分享:http://chinadenli.net/article28/hsgejp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊網(wǎng)站排名移動網(wǎng)站建設(shè)ChatGPT網(wǎng)站營銷品牌網(wǎng)站設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)