PHP: Pengiraan Jumlah Pengunjung
|
Salam, ni aku nak kongsikan coding untuk mengira jumlah pengujung ke website kita. boring beb!
step 1: Code yang ni letak atas sekali dalam page. Pastikan database dah buat.
session_start();
if(isset($_SESSION['ip3']))
{
mysql_select_db($database_connection, $connection);
$query_count = "SELECT * FROM `count`";
$count = mysql_query($query_count, $connection) or die(mysql_error());
$row_count = mysql_fetch_assoc($count);
$totalRows_count = mysql_num_rows($count);
$total = $row_count['total'];
}
else
{
mysql_select_db($database_connection, $connection);
$query_count = "SELECT * FROM `count`";
$count = mysql_query($query_count, $connection) or die(mysql_error());
$row_count = mysql_fetch_assoc($count);
$totalRows_count = mysql_num_rows($count);
$total = $row_count['total']+1;
include('connection.php');
$sql = "update count set total='$total' where id='$row_count[id]'";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$_SESSION['ip3'] = 1;
}
step 2: Dan yang ni code untuk display counter viewer. letak je tempat yang rasa korang suka.
if(strlen($total)==1) {echo "00000000".$total."";}
elseif(strlen($total)==2)
{echo "0000000".$total."";}
elseif(strlen($total)==3)
{echo "000000".$total."";}
elseif(strlen($total)==4)
{echo "00000".$total."";}
elseif(strlen($total)==5)
{echo "0000".$total."";}
elseif(strlen($total)==6)
{echo "000".$total."";}
elseif(strlen($total)==7)
{echo "00".$total."";}
elseif(strlen($total)==8)
{echo "0".$total."";}
elseif(strlen($total)==9)
{echo "".$total."";}
Ni sample yang aku buat:
POSTED BY juong |
Popular Posts
-
Rumi Ke Jawi 1. Convert rumi ke jawi secara online. senang sekali! 2. Lepas covert, copy dan paste kat microsoft word, 3. dan pilih font ...
-
Sebelum download Arabic Dotted / titik-titik, Aracbic font perlu di install terlebih dahulu. Install arabic font di sini Kalau dah install, ...
-
Encoding JSON in PHP Some years ago, JSON support was provided through the json pecl extension. Since PHP 5.2, it is included in the core ...
-
There are many options to change default icon of File Extension. For example we can uses FileTypesMan application, or using manual setting. ...
-
In Windows 8, now that the Start Menu is now gone and replaced by the Start Screen and Charms bar. This means that if you want to restart yo...
-
Not set up a security code so that anyone trying to access your phone will need to code to get into it. Press the Nokia Menu key to the left...
-
maybe.
-
Mengetahui seseorang itu anak yang ke berapa dalam keluarga dengan menggunakan rumusan matematik. Sebagai contohnya: Dalam keluarga anda t...
-
Pelupusan Sampah dengan cara yang betul amat penting demi kesejahteraan alam ini. Kitar Semula merupakan salah satu cara untuk melupuskan sa...
-
Assalamualaikum, selamat bertandang ke blog juongjournal. Hari ni, 4.5.2011 aku nak kongsi doa qunut. semoga posting ni mendapat keberkatan ...
Post a Comment