Jump to content


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

  • Please log in to reply
1 reply to this topic

#1 the apprentice webmaster

the apprentice webmaster
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts

Posted 04 April 2006 - 09:49 AM

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 ,

#2 wildteen88

  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 April 2006 - 10:46 AM

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:

+- pid
+- name
+- price

... more rows here ...

+- catid

Now you categories table will look like this:
+- 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.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users