Assuming you have access to a MySQL server and can create a database ...
1) Create Your Database
Lets name it: counters
You can do this by using a sql query like:
CREATE DATABSE `counters`;
2) Create your table(s)
Lets name a table tickers
In this table, lets make the following fields.
id - Record ID (We will set to auto count)
ticker_id - Ticker ID
count - The actuall count
You can create this table by using a sql query like:
CREATE TABLE `tickers` (
`id` BIGINT NOT NULL AUTO_INCREMENT ,
`ticker_id` BIGINT NOT NULL ,
`count` BIGINT NOT NULL ,
PRIMARY KEY(`id`) ,
INDEX(`ticker_id`)
) TYPE=MYISAM COMMENT=`Ticker Database`;
3) Create Your PHP And Connect To The Database
Now, its time to use PHP. Create your script that will handle making the image, assuming with the gd library. Also, you want to connect to the database, again, assuming you will use the basic php mysql extension. To connect to your mysql server do something like the following:
// Set some variables. Not a totally secure way, but works.
$db_host = 'dbserv5.myserver.com';
$db_user = 'itsme';
$db_pass = 'donttellanyone';
$db_base = 'counters';
// Before we forget, whats the id number for our counter?
$counter_id = $_GET['id'];
// Connect to the server and show an error if it didnt work.
mysql_connect($db_host, $db_user, $db_pass) or die("Couldn't connect to serv.");
mysql_select_db($db_base) or die("Connected, but couldnt open database.");
// Our query.
$query = "UPDATE `tickers` SET `count` = `count` + 1 WHERE `ticker_id` = $counter_id LIMIT 1; SELECT `count` FROM `tickers` LIMIT 1;";
$result = mysql_query($query);
$count = mysql_fetch_array($result);
// Now, your counter has been updated and returns the newest number. You can access this by doing:
$counters_number = $count['count'];
// or
$counters_number = $count[0];
Some might say that you need to store mysql_connect()'s resrouce into a variable, so you can free it later. Becuase we are not keeping a connection open, it is automaticly closed when the script is done, so you dont have to worry about that.
If you have any questions, feel free to ask.