Jump to content

Archived

This topic is now archived and is closed to further replies.

the apprentice webmaster

mysql database issue help...........

Recommended Posts

hi to all you guys , i got a question for you guys , i am having a problem with that , i wanna create some categories table n also some product table , but i don't really know how to go about it , for example
i got : x-box , ps2 , psp, gamecube , pikachu toys , suppercar , drill set , ashley posters
and i have : toys , games ,poster , hardware , etc

so guys my question is between them , which one can be place into the product table , and which one can be placed into the category table , i don't know if i explain it well n precise , any input , any help will be appreciated , thx in advance , i 'll be online for another hours ,

Share this post


Link to post
Share on other sites
You'll want to create two tables called products and cateogries. In the products table you store all your products that you have when you create your table make sure you create an extra row cam call that catid as this will be used for getting the correct products for each category. SO you products table will loook like this:

Products
|
+- pid
+- name
+-description
+- price

... more rows here ...

+- catid

Now you categories table will look like this:
Cateories
|
+- cid
+- name
+- description

Now when you do your MySQL Query you'll want to do it like so:
SELECT * FROM products WHERE catid = $_GET['cid']

$_GET['cid'] is passed over the url like so: products.php?cid=1

Then the sql will be ran and will get all the products with the catid of 1.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.