Your Ad Here
 
Samay Live
 
EBooks » Web Tutorials
[1] [2] [3] [Page 4] [5] [6] [7]

This tutorial aplies to anything like page.php?var=stuff&var2=stuff. Let me define a few terms to start: 'query string' is the ?page=blah part in 'page.php?page=blah'. page=blah is called a variable=value pair. You can seperate them by doing 'page.php?var1=bob&var2=tom'.

Now, something that will cause many of you problems is register_globals. If its off (which it is by default in the last few php distrubs), using $queryStringVar when going to page.php?queryStringVar=tom wont print out anything. In fact, chances are it will give you an unset / undefined variable error... whcih isnt good! But we have a soultion.

Remember the variable=value pairs? We can get things from the query string through the $_GET array, no matter what. So since $queryStringVar doesnt work, we have to get it through $_GET['queryStringVar'].

Ever wanted to learn how to do that? Loading pages through the index? Well I will teach you how to do it a good way, fast and secure.
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.

[1] [2] [3] [Page 4] [5] [6] [7]
 
Username:
Password:
 
Sign Up | Lost Password
 
 

Execution time : 0.00588512420654