Trying to understand the basis of php for an online catalog

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
Vestax159
Forum Newbie
Posts: 12
Joined: Thu Feb 18, 2010 3:24 pm

Trying to understand the basis of php for an online catalog

Post by Vestax159 »

Im trying to wrap my head around how a php based online catalog works.

Firstly, you establish your categories in a database and display them by calling each row. So for the example we will use the category of dogs. When you select the dog category you run a query which returns each product listed under dogs and you then display each row for the product list. When you select a product you are essentially selecting a row in the database which you then display that information for (product name, description, etc).

Now I think my difficulty is the product urls. Say I select the dog named Abby how do I produce a url like http://www.dogsforsale.com/Abby. For some reason I am finding it difficult to understand this concept without knowing how to establish a unique url for each product. Is it simple created based off the criteria I use to identify each row (Normally the primary key) or can I create a column named product url and assign that as the url?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Trying to understand the basis of php for an online catalog

Post by Eran »

Those are called clean-URLs. You should be directing traffic into one script that will accept a variable (or more) describing what page / product should appear. The most common way to achieve this is using apache's mod_rewrite
http://wettone.com/code/clean-urls
Vestax159
Forum Newbie
Posts: 12
Joined: Thu Feb 18, 2010 3:24 pm

Re: Trying to understand the basis of php for an online catalog

Post by Vestax159 »

Forgive me, I see how that could change a url to be cleaner but could I make it change an items url to match that of a sql cell?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Trying to understand the basis of php for an online catalog

Post by Eran »

You should be directing traffic into one script that will accept a variable (or more) describing what page / product should appear.
The script should get the variable from the URL and fetch the required row from the database
Post Reply