View difference between Paste ID: Csfag9nX and wNGiGd6p
SHOW: | | - or go back to the newest paste.
1
<?php
2
setcookie("counter","visitor",time()+3600);
3
4
include "conn.php";
5
6
$tanggal=date("Y-m-d H:i:s");
7
echo "<br/>tanggal=$tanggal";
8
if (!isset($_COOKIE['counter']))
9
{
10
	echo "<br/>cookie tidak ada";
11
$query = mysql_query("select * from counter where tgl='$tanggal'");
12
while ($rows=mysql_fetch_array($query))
13
{
14
	$visit=$rows[1];
15
}
16
	echo "<br/>visit = $visit";
17
}else{
18
	echo "<br/>cookie ada";
19
}
20
21
if (empty($visit))
22
{
23
	mysql_query("insert into counter values('$tanggal',1)");
24
	echo "<br/>insert 1";
25
}
26
else
27
{	$visit=$visit+1;
28
	mysql_query("update counter set jml='$visit' where tgl='$tanggal'");
29
	echo "<br/>update";
30
}
31
32
33
34
$hariini=date("Y-m-d");
35
$query=mysql_query("select distinctrow sum(jml) as tot from counter where year(tgl) = left('$hariini',4) and month(tgl) = mid('$hariini',6,2) and day(tgl) = mid('$hariini',9,2)");
36
while ($rows=mysql_fetch_array($query))
37
{
38
	$jmlhariini=$rows[0];
39
/*
40
disini akan di kumpulkan nilai counter hari ini saja.. jadi kl di refresh
41
maka disini akan bertambah 
42
*/
43
}
44
45
$query=mysql_query("select distinctrow sum(jml) as tot from counter");
46
while ($rows=mysql_fetch_array($query))
47
{
48
	$totvisit=$rows[0];
49
/*
50
total keseluruhan counter
51
*/
52
}
53
54
55
?>
56
57
<html>
58
<body>
59
	<table align="left" border="0" width="100%">
60
	<tr>
61
	<td>
62
	<font face="verdana" size="1" color="#000000"><center><?php echo $jmlhariini?> hits today, <?php echo $totvisit?> hits since 21/04/11 </font>
63
	</td>
64
	</tr>
65
	</table>
66
67
</body>
68
</html>