Jump to content

Linking MySQL tables


pogester

Recommended Posts

Hi there, am looking for some help with the php database I am working on, I am creating an event listing for a local magazine site and currently have 2 tables in my database which are

 

LISTING

id, date, time, event, venue, cost, contact details, other info

 

VENUE

id, venue, address, postcode, telephone, contact, email, website, more info

 

I am looking to link the venue field in LISTING to the VENUE database so that each venue comes up as a link in the list which when click loads up the venues page with the info and all events at that venue.

 

Everything I look at seems to cover bringing in info from two tables into one form but I want to bring in the venue as a link in the main form rather than bringing in info from the VENUE table.

 

Hope that makes sense and any help will be most appreciated, many thanks

 

Darren

Link to comment
Share on other sites

Well you need to make a query to show which venue belongs to which listing. What is the Foreign key in your listing table that links to your Venue table?

 

What is the venue column do in both tables?

 

How I would do this (with mysql first, before linking everythnng up in PHP)

 

 

LISTING

listing_id, date, time, event, venue_id, cost, contact details, other info

 

VENUE

venue_id, venue, address, postcode, telephone, contact, email, website, more info

 

SELECT
l.listing_id,
l.venue_id,
l.event,
v.venue_id,
v.venue
FROM
listings l INNER JOIN venue v ON (v.venue_id = l.venue_id)

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.