pogester Posted February 15, 2009 Share Posted February 15, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/145332-linking-mysql-tables/ Share on other sites More sharing options...
Cosizzle Posted February 15, 2009 Share Posted February 15, 2009 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) Quote Link to comment https://forums.phpfreaks.com/topic/145332-linking-mysql-tables/#findComment-762954 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.