Moderator
From: Yorkshire, UK
Registered: 2006-08-19
Posts: 2669
I've been thanked 63 times.
Offline

A templated page could work like this
link: www . my-site.com/info.php?product=xyz
The browser makes a request to the server for that URL, the server recognises the ? part as the query string and actually gets the file "info.php".
The file info.php now has access to the variables passed to it in the query string, ie product=xyz and is available to the PHP script as $_GET['product']
the php
Code: php
<?php
echo $_GET['product'];
?>
would output
Code: html
xyz
to the browser
Using mysql, php can query a database and get more information. For example 'xyz' may relate to a record in a database that has the name of the product, a description and the name of an image.
If you put all the text you want into variables, you can just include your template file which might look like this (really basic):
Code: php
<html>
<head>
<title><?= $product['title'] ?>
</head>
<body>
<h1><?= $product['title'] ?></h1>
<p><?= $product['description'] ?></p>
<img src='images/<?= $product['image'] ?>' />
<a href='add-to-cart.php?id=<?= $product['id'] ?>'>Buy Now</a>
</body>
</html>
The clever parts come when you try to make content from content that doesn't actually exist. For example I don't store meta keywords in the database; I use php to concatenate all of the content on the page into one string, then do a word count on the string (minus stop words) and put the top few in the meta keywords part of the page.
If you name your images sensibly then you don't even need image names in the database (eg if every image named after the product ID in the database and in a folder called /product-images then I know what the image name is based on the product ID, which was in the query string in the first place!!!
The other thing you'll want to know about is database design - any fool can put together a database table, but some people don't even know about database keys or indexing - as a matter of course every database table should have some sort of unique ID for each row. This is usually an auto-incrementing integer; but could be a natural key if you know for sure that a particular row will never have any duplicate entries
Internet Marketing Books
Promote Yourself on Site Reference!
| Never |


