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>
Convert a File database into MySQL Categories : PHP , Filesystem , Databases , MySQL , Beginner Guides Introduction to Language Files Categories : PHP , Filesystem , Beginner Guides A flat file counter Categories : PHP , Cookies , Filesystem , Beginner Guides Selecting a random line from a text file Categories : PHP , Filesystem , Arrays , Beginner Guides Random Image Display Categories : PHP , Filesystem , Graphics , HTML and PHP 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 Read DPI value from image with PHP Categories : PHP , Graphics , Filesystem Creating a Language File Categories : PHP , Beginner Guides , Filesystem 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 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 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 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 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 PHP Image Validation Class - test if a specific file is of a certain image type without relying on the said file extension. Categories : PHP , PHP Classes , Data Validation , Graphics , Beginner Guides