Sometimes you may want to pass something in the URL to extract and use on a following page. For instance you may have a list of items in a table and want to be able to them find out further information Example:

Apple

Banana

Pear

You might want to find information about each item in further page e.g. apple.html, banana.html and pear.html. If you have a long list of items this can then become time consuming. An alternative is to have this data in a database and use a general page to extract the relievant information for the item of interest.

SELECT price, origin, company FROM fruit where item ='{$_GET[‘item’]}’

Beware, both methods are trusting that the item value is real. In a real application, this value needs to be checked to prevent SQL injections etc. Also, this method should not be used to pass sensitive info e.g.

This entry was posted
on Thursday, February 15th, 2007 at 12:26 pm and is filed under Coding.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.