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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.