|
|
|
In this small example we are going to build a simple web counter.
First of all we read a text file in which we store our counter value. Depending on that value we display the counter value using images. Then we increase the counter value by 1 and write back to the text file.
Really simple script for beginners.... Will work well on low traffic sites where there is little chance for diffrent users to overite each others updates.
| <?php
$fp = fopen ("counter.txt", "r");
$count_number = fread ($fp, filesize ("counter.txt"));
fclose($fp);
?>
<html>
<head>
<title>Counter number</title>
</head>
<body>
<center>
<?php
$counter = (int)($count_number) + 1;
$count_number = (string)($counter);
$len = strlen($count_number);
while($len!=$i && $len!=0)
{
echo "<img src=". $count_number[$i].".jpg alt=\"visitor number $count_number\" width=20 Height=22>";
$i++;
}
$fp = fopen ("counter.txt", "w");
fwrite ($fp, $count_number);
fclose($fp);
?>
</center>
</body>
</html> | |
|
|
| Introduction to Language Files Categories : PHP, Filesystem, Beginner Guides | | | PHP Email image generator - hide your email from bots - using the GD Library Categories : PHP, Graphics, GD image library, Beginner Guides | | | PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP, Email, Beginner Guides, Filesystem | | | Convert a File database into MySQL Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides | | | This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs | | | A flat file counter Categories : PHP, Cookies, Filesystem, Beginner Guides | | | Random Image Display Categories : PHP, Filesystem, Graphics, HTML and PHP | | | How to display any array in several rows and columns of a table. Not just
in one column or in alternate rows. This example shows a nice color table
generated with PHP, but can be used with any array values(e.g. Database) Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics | | | Easy slideshow with php. Just place this one file into a subdirectory where jpg files reside. An instant slideshow is yours. MS explorer only. Categories : PHP, Filesystem, Graphics | | | Creating a Language File Categories : PHP, Beginner Guides, Filesystem | | | This program implements hot link prevention in php. It is useful for webmasters who do not have access to the server at a level where they can control hot linking can still supply some type of hot link prevention for thier site by using php. Categories : PHP, Filesystem, Graphics, Content Management | | | This script will read all images from a folder and read the files into an array. It uses rand() to get a random number. It will display a random image from the image folder given. Categories : PHP, Arrays, Graphics, Filesystem | | | Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs | | | PHP4 DirectoryIterator Class Categories : PHP, PHP Classes, Filesystem, Directories | | | Keep() - maintenance function for backup folders Categories : PHP, Filesystem, Maintenance | |
|
|
|