Arch design for many similar pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tequila27
Forum Newbie
Posts: 2
Joined: Mon Sep 07, 2009 10:24 am

Arch design for many similar pages

Post by tequila27 »

I want to have several similar pages. Each page is based on the same template. I would like to have the individual page instances be generated from a table which contains the page-specific info (perhaps a row for each page's values - e.g. Color="red"; Price="$9.95). The php template would then look up that page's info in the table. Of course, there would have to be an index into the table so as to know which row's value to grab for the page. If I were to use a numerical index, then I would have to copy the template for each page and have that single numerical index be different on each copied instance of the template. The only other idea I had
was to read the name of the current file and use that as an index into the table.

Of course, since I've starting learning PHP exact two days ago, perhaps there's a better overall way to architect this so I can have many similar pages with table-driven content.

Thanks in advance for any help.
Thanaton
Forum Newbie
Posts: 2
Joined: Mon Sep 07, 2009 10:52 am

Re: Arch design for many similar pages

Post by Thanaton »

It sound like you are searching for the following:

With the global $_GET variable, you can read values from the URL. So, for example, if the url is 'http://www.example.nl/index.php?item_id=55', then $_GET['item_id'] has the value 55.

Then you can get all the info you want from a (normalized!) database: Price, color, name, etc...

This way you can have a single page in which different data can be included by using the url!

Greeting,
Thanaton

PS. My first post, so I hope this is helpful!
Post Reply