Jump to content


Photo

linkup table


  • Please log in to reply
2 replies to this topic

#1 sim0ng

sim0ng
  • New Members
  • Pip
  • Newbie
  • 7 posts
  • LocationEngland

Posted 11 September 2006 - 12:09 AM

I'm in the process of recoding my cms and want to make catagories for content to be put under and would like a bit of help on how to create a linkup table.

I have got this so far for the main content

mysql_query($strsql);
	$strsql = "CREATE TABLE sim0ngportal_manuals_pages (id MEDIUMINT  UNSIGNED NOT NULL AUTO_INCREMENT,title VARCHAR(255), description MEDIUMTEXT , startpage CHAR(1), PRIMARY KEY (id));";

I will create a new table called "sim0ngportal_manuals_catagories" with just a field to insert catagory names, will probably be called "catagory_name" to keep things nice and simple.

Now, how do I then link the 2 together? do i need to create a forin key yo go to the other table? and how do I join it?  Have heard that I can use something like "INNER JOIN" but I'm not sure if thats correct or how exactly to use it.


Any help would be great
cheers :)

#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 11 September 2006 - 12:13 AM

You need a column in your content table called category_id or similar, and this will link to the category_id column in your new category table.

Regards
Rich
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 sim0ng

sim0ng
  • New Members
  • Pip
  • Newbie
  • 7 posts
  • LocationEngland

Posted 11 September 2006 - 12:18 AM

right, okay, should I put it in like this??

,category_id int(11)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users