This tutorial is a bit more difficult then my others because
it requires MySQL. Some coding is needed in the SQL language
and getting access to a Database may prove to be hard, a free
host with MySQL is unheard of, however even the smallest paid
packages usually come with SQL. Im gonna write this tutorial
assumimg you already have minimal knowledge of SQL Databases.
Creat in your database a table named 'clickcounter' with the
properties like the code below.
// CREATE TABLE clickcounter (
// id int(11) NOT NULL auto_increment,
// url varchar(50) NOT NULL default '',
// count smallint(3) NOT NULL default '',
// PRIMARY KEY (id)
Ok, first you will need to make the connection to your
database. Is what this first line does. If u donīt know how
to make the connection to your database i will have a tutorial
up for it soon.
// Youīll call some id in the table through the '$id'
// Increment the count field value of the requested
$update = mysql_query("UPDATE clickcounter SET
count = count + 1 WHERE id='$id'");
// Select the requested id on the database..
$result = mysql_query("SELECT url FROM
clickcounter WHERE id='$id'");
// Retrieve the data(url) of url field.
$row = mysql_fetch_array($result);
$url = $row[url];
// Redirect to the url and close the database.
Thatīs all. Now save this file as click.php.
Call this script making something like this:
This PHP tutorial was clicked 168 times
Tutorial By Xtasy