programmingsite : code , tutorials and scripts
Navigation

home


ASP
ASP.net
PHP
JavaScript
C
C++
Java
Visual Basic


Resources
code
tutorials
training

Ads
Products

 

 

Create a graphical counter




Create a graphical counter

Not too difficult and the concepts are much the same as our basic text counter .

Grab some counter artwork , we suggest counterart for some fine examples
Create a file in this example it is called counter.txt and enter a starting number.
Upload this to your server and on UNIX servers chmod to 755.
Copy the following code into a new file called grcounter.php
Insert the following code on the page where you wish the counter to appear.

<?php include("grcounter.php"); ?>

Thats it.


<?php
//create a file called counter.txt and upload it to your server
//now open the file
$fp = fopen("counter.txt" , "r");
//read in the current count
$count = (int)fread($fp, 1024);
//increment the count by 1
$count++;
//close the file
fclose($fp);
//image display, get the lentgth of the count
for ($i = 0 ;$i < strlen($count) ; $i++)
{
$imgsrc = substr($count,$i ,1);
//display the image(s) note our images are in a folder located at
//images/count1/ change this to your location
echo "<img src =\"/count/01/" . $imgsrc . ".gif\">";
}
//open the counter file
$fp = fopen("counter.txt", "w");
//write the new count to the file
fwrite($fp, $count);
//close the file
fclose($fp);
?>

And below you can see this in action







Products
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals
Asp Studio 2005
Xtra PHP
Online PHP Script Encoder
Comparison

Links
Make money selling software
Golf resource site
UK price comparison
UK shopping
free articles
free stuff
Gambling resources
Software directory
Health and fitness
Sexy free wallpapers
Hosting resources
ASP site
Beginners PHP
Anime videos
Domain names
Dating site
Programming resources
Dropshippers
Maxi directory
free recipes
Coupons and deals
iPod resources

Ads