Jump to content

Inserting an option of 4 things into database


dc_jt

Recommended Posts

Hi

I have a table called listings which contains name, address, telephone etc of each advertising listing.

Each listing has a choice of 4 types (Listing Ad, Quarter Size, Half Size, Full Size).

Each listing only has one type.

What is the best way to insert one of these types into my listings table?

I was thinking of having a checkbox for each on my form like:

Listing Ad      []
Quarter Size  []
Half Size      []
Full Size        []

Then whatever one is clicked goes into the table listings.

However, do i have a separate table for the types or do i put them all in the listings table, im not sure?

Hope someone can help asap please

Thanks
I would have a seperate table for listing types. eg;

[code]
CREATE TABLE listing_types (
  id INTEGER PRIMARY KEY,
  type_name VARCHAR(80)
)
[/code]

Populate it with data. eg;

[code]
1 Listing Ad
2 Quarter Size
3 Half Size
4 Full Size
[/code]

Then, in listings have a field called listing type which is populated with the number corrisponding to the type selected.
Yeah I thought that was the best way.

Now from my form, I have an AddListing function which inserts name, address, telephone etc into the listings table so do I just run another function which inserts the listing type and the listing id in the listing type table?

Do I have to join them using INNER JOIN or anything?

Thanks

Archived

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

×
×
  • Create New...

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.