bezoekers-teller
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
function teller(){
if(mysql_result(mysql_query("SELECT COUNT(1) FROM teller WHERE ip='".$_SERVER['REMOTE_ADDR']."';"), 0, 0 ) > 0){
if(mysql_query("UPDATE teller SET aantal=aantal+1 WHERE ip='".$_SERVER['REMOTE_ADDR']."';")){
return true;
}
}else{
if(mysql_query("INSERT INTO teller SET aantal=1, ip='".$_SERVER['REMOTE_ADDR']."';")){
return true;
}
}
return false;
}
function visits(){
if($result = mysql_query("SELECT COUNT(1) as uniek, SUM(aantal) as totaal FROM teller")){
return mysql_fetch_assoc($result);
}else{
return array('uniek' => 0, 'totaal' => 0);
}
}
?>
function teller(){
if(mysql_result(mysql_query("SELECT COUNT(1) FROM teller WHERE ip='".$_SERVER['REMOTE_ADDR']."';"), 0, 0 ) > 0){
if(mysql_query("UPDATE teller SET aantal=aantal+1 WHERE ip='".$_SERVER['REMOTE_ADDR']."';")){
return true;
}
}else{
if(mysql_query("INSERT INTO teller SET aantal=1, ip='".$_SERVER['REMOTE_ADDR']."';")){
return true;
}
}
return false;
}
function visits(){
if($result = mysql_query("SELECT COUNT(1) as uniek, SUM(aantal) as totaal FROM teller")){
return mysql_fetch_assoc($result);
}else{
return array('uniek' => 0, 'totaal' => 0);
}
}
?>
Voorbeeld:
Het volgende sctipt:
Code (php)
Zou deze output kunnen opleveren: