Your Ad Here
 
Samay Live
 
EBooks » Web Tutorials
[1] [2] [3] [Page 4] [5] [6] [7]
The way this counter works is it creates a cookie on the user's computer with their IP and it updates the count according to the status of that cookie. If the cookie is present and the IP in the cookie is the same as the user's current IP then the script knows the user has already been there and it does nothing or if it is present, but has an IP different than the user's current IP or is not present the script knows that the user is either new or was there before, but the cookie has expired so it then updates the count. This script will be using the setcookie() function, which must be sent before any headers are sent. Basically what that means is that it must be placed before any HTML. The count will be held in a text file for ease of use but if you desire to use a database that is perfectly acceptable.
This is for my friend from Morroco

Introduction


This tutorial is designed to guide you through the logic and code behind the process of paginating data in PHP. In this tutorial, the data is retrieved from mySQL database. I feel you will be able to grasp this tutorial better if you have a decent knowlege of PHP and mySQL. However, I plan to comment code as much as possible and describe the why we do each part.

What is Pagination?


There might be a few of you who are clueless to even what pagination is. For those with question, pagination is where you have more data that desired appearing on one page, and breaking up that data so that it is then presented on multiple pages. It is very likely that you have seen this before.
Maybe you notice at the very bottom of some sites, the page numbers are listed and either "Previous" or "Next" to the left and right.

This is a simple random image script which is ideal for displaying basic images from a text file . In future examples we will expand on this and build some simple banner rotation systems.

The first step that you need to do is to create your file for storing your images and then insert the names of the images.

In the example here I called the file images1.txt .

Each one of the entries is on a seperate line and in this case because I stored the files in a sub-directory I inserted that also . the structure of the file was like this

image/banner1.gif
image/banner2.gif
image/banner3.gif

and so on. Now we get to the script that will display a random image and again this is straight forward enough.

It's the Information age, and information can't be contained, it grows by the second. Hence no single site can suffice the needs of today's visitor be it Yahoo! or any other site. Internet is a whole new medium and tracking of 100's of portal start ups is annoying, but still you wander about here and there. Agreed that bookmarks make life much simpler, but easier hmm...

Today I'll discuss how to grab stuff from all these happening places, I'll take the example of Yahoo! NewsPod, probably the most successful script for grabbing news from Yahoo!

The base methodology behind "grabbing" content is RegEx, which allows you to grab a certain portion of the obtained content.

Linear Working : (1) A socket (behind the scenes) connection to http://www.yahoo.com/index.html
(2) Reading a pre-determined (or filesize determined) bytes of the page and storing into array
(3) Searching for particulars and storing into another variable
(4) Sorting out further for extra customization
There are many situations where you might want to display up-to-date information on your website. I will use the process of displaying the latest headlines from Slashdot.org as an example here.

Getting the headlines

The file http://slashdot.org/slashdot.xml contains the current slashdot headlines for people to use on their websites. You could just load the data from this file every time someone visits your page. However, Slashdot requests that you only access the file once every 30 minutes or more (to reduce the load on their server). This means we will need a better strategy for making sure we have up-to-date headlines.

You could use cron to perform the update once every 30 minutes but for various reasons this might not be possible. My approach is to write a PHP script that does the following when a user loads the page with the dynamic content:

1. Check whether a local (i.e. on my webserver) copy of slashdot.xml has been updated within a predefined time period (more than 30 mins in this case).
2. If it has not been updated recently enough then download the current one from slashdot.org.
3. Display the data from the local copy of slashdot.xml.
[1] [2] [3] [Page 4] [5] [6] [7]
 
Username:
Password:
 
Sign Up | Lost Password
 
 

Execution time : 0.00771617889404