I'm creating a classifieds website... I've these 6 tables: Every category has sub-groups (or options) which you'll see below.

Allows the user really wants to publish a classified, and it has joined all info in to the forms necessary, and i'm at where I must produce the PHP code to really Place the information in to the database.

I'm thinking something similar to this:

mysql_query("INSERT INTO classifieds (classified_id, ad_id, poster_id, cat_id, area_id, headline, description) VALUES ($classified_id, '$ad_id', $poster_id, $cat_id, $area_id, '$headline', '$description')");

But I'm not sure where you can children here... I believe the posters table shouldn't be such as this, because how must i figure out what the poster_id ought to be? Or must i place it to auto-increment? Don't forget this, posters might not sign in or anything, so there's not a problem with one individual getting multiple poster_table records if guess what happens I am talking about.

classified_id is really a random unique value produced by PHP to ensure that is definitely unique.

Please guide me! I'm not sure how you can link the tables together properly.

For those who have any Q tell me and that i will update this Q!

category table:
cat_id (PK)
cat_name

category_options table:
option_id (PK)
cat_id (FK)
option_name

option_values table:
value_id (PK)
option_id (FK)
value

classifieds table:
classified_id (PK)
ad_id (VARCHAR) something like "Bmw330ci_28238239832" which will appear in URL
poster_id (FK)
cat_id (FK)
area_id (FK)
headline
description
price
etc....

posters table:
poster_id (PK)
name 
email
tel
password

area table:
area_id (PK)
area
community

You have the best idea already. When someone produces a publish, and makes its way into their personal info, FIRST place the "poster" record in to the posters table. The "poster_id" primary key for your table ought to be a car_increment area.

Next, obtain the ID from the new poster you simply produced using PHP's "mysql_place_id". That integer value would be the number you devote the "poster_id" foreign key area within the "classifieds" table.

You need to usually set the main answer to a car-increment area.

If you have linked tables and you have to join around the id, you are able to first place in to the primary table after which make use of the function mysql_insert_id to retrieve the id from the element you simply placed. After that you can place in to the other table by using this value because the foreign key.

This can be a very standard method of doing things, so it ought to be acceptable for you.