我直接在這給你修改答案算了
我們提供的服務有:成都網(wǎng)站制作、成都做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、建湖ssl等。為上1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術的建湖網(wǎng)站制作公司
使用的時候刪除行號
修改數(shù)據(jù)庫配置
如果想使用
頁面不刷新查詢數(shù)據(jù)庫
需要使用JQUERY
如果有需要給我留言
1
?php
2
if(isset($_POST['submit'])$_POST['submit']=='提交'){
3
//判斷是否是提交過來的
4
$intext
=
$_POST['intext'];
5
if($intext!=null||$intext!=''){
6
$link
=
mysql_connect("localhost",
"root",
"123456");
7
//數(shù)據(jù)庫配置信息
第一個參數(shù)數(shù)據(jù)庫位置第二個是用戶名第三個是密碼
8
mysql_select_db("szn_test");
9
//設置要使用的數(shù)據(jù)庫
10
$sql
=
"select
*
from
demo
where
res
=
'".$intext."'";
11
//SQL語句
12
var_dump($sql);
13
$res
=
mysql_query($sql);
14
$arr
=
array();
15
//吧結果存入數(shù)組
并記錄數(shù)組長度
16
$count
=
0;
17
while($data
=
mysql_fetch_array($res)){
18
$arr[$count]
=
$data;
19
$count++;
20
}
21
//關閉數(shù)據(jù)庫
22
mysql_close($link);
23
}
24
}
25
26
?
27
html
28
head
29
title/title
30
/head
31
body
32
form
id="form1"
method="post"
action="demo.php"
33
input
type="text"
name="intext"
34
input
type="submit"
name="submit"
value="提交"
35
/form
36
?php
37
if(isset($arr)$arr
!=
null){
38
for($i
=
0;
$i
$count;
$i++){
39
foreach($arr[$i]
as
$key
=
$value){
40
echo
"key:".$key."
value:".$value;
41
echo
"
";
42
}
43
echo
"br";
44
}
45
}
46
?
47
/body
48
/html
這個是數(shù)據(jù)庫查詢代碼
你可以看以下對照著修改修改
//先創(chuàng)建一個log表,有id, action, username, query, time 等字段,如果需要記錄更多,可添加
$query_string = $_SERVER['QUERY_STRING'];//查詢(query)的字符串,這個最好處理一下
$action = $_REQUEST['action'];//操作類型,可以自己定義。比如?action=addid=xx
//$username就是當前操作人的名字了,登錄后都有的吧
if(in_array($action, array('add', 'edit','delete','update')))
{
addlog($action,$username,$query_string);
}
function addlog($action,$username,$query_string)
{
//這里可以把時間和$query_string處理一下,插入數(shù)據(jù)庫
$db-query($sql);
}
大致思路就是這樣的了,細節(jié)還需你自己完善
設計一張瀏覽文章表,字段用自增id、文章id、用戶id、瀏覽時間、ip、客戶端信息。。。
用戶每訪問一次文章就向表中添加一條數(shù)據(jù)
查詢某文章瀏覽量就是select count(*) from 瀏覽表 where 文章id=:id
查詢某文章用戶總量 select count(*) from 瀏覽表 where 文章id=:id group by 用戶id
解決方案:
插入數(shù)據(jù)庫
$db-先創(chuàng)建一個log表, '],有id,$username;];update',登錄后都有的吧
if(in_array($action, action;$username就是當前操作人的名字了;;/, username;這里可以把時間和$query_string處理一下,',可添加
$query_string = $_SERVER[', query;, time 等字段,可以自己定義;delete',$username,$query_string);edit',如果需要記錄更多。比如;)))
{
addlog($action;/QUERY_STRING',這個最好處理一下
$action = $_REQUEST['///查詢(query)的字符串?action=addid=xx
/,'action';操作類型, array('add'/
}
function addlog($action,$query_string)
{
/query($sql);
}