junglyboi Posted November 12, 2006 Share Posted November 12, 2006 ok i have a page where i'm trying to show the details of an upcoming concert. An example is www.ticketstone.com/shows.php?show=1I have all the tables in place and such. In my 'shows' table, I have a field for 'headliner_1', 'headliner_2', 'headliner_3' and so on. Then I have an 'artists' table, where 'artist_id' should match up with 'headliner_1' or 'headliner_2' and so on.Ok, here's my question. On the page where I'm displaying the show details, I need to show a list of all artists playing that show. So I would show headliner_1, headliner_2, headliner_3, and so on as long as they are not null. But I need to pull in their name, website and additional info from the artists table. So how do I pull the informaiton for say headliner_1 in one spot, headliner_2 in another spot, etc.?I probably need help with the SELECT statement as well as knowing how to tell it that in this specific spot on the page, I want the information for headliner_1, and over here I want the info for headliner_2, etc. Make sense? Quote Link to comment https://forums.phpfreaks.com/topic/27015-one-to-many-i-think/ Share on other sites More sharing options...
chiprivers Posted November 12, 2006 Share Posted November 12, 2006 Is there always the same number of headliners and are they located in various positions across the page?I would do a query for each headliner and use:SELECT * FROM shows, artists WHERE shows.headliner_1 = artists.artist_ID Quote Link to comment https://forums.phpfreaks.com/topic/27015-one-to-many-i-think/#findComment-123530 Share on other sites More sharing options...
junglyboi Posted November 12, 2006 Author Share Posted November 12, 2006 there is always a headliner_1, but not always headliner_2, etc. so I know I'll have to use some IF statements to determine if those cells in the table should populate... so for example, if there are 5 headliners, my table will have 5 cells across, if there's only 1 headliner, then just 1 will be in the center... i get how to do all thatbut once i've determined, which headliners exist for the show, i don't know how to put them in the right place with the right info ... example:[code]<td>headliner 1 info</td><td>headliner 2 info</td><td>headliner 3 info</td><td>and so on...[/code] Quote Link to comment https://forums.phpfreaks.com/topic/27015-one-to-many-i-think/#findComment-123540 Share on other sites More sharing options...
junglyboi Posted November 12, 2006 Author Share Posted November 12, 2006 oh you know what i think you did answer my question... (thinking out loud) cus if the cell for headliner 2 is contained in an IF statement, then i can check the main query to see if headliner_2 contains info... then if it does, SELECT headliner_2 info from the artist table...i'll give that a try :D Quote Link to comment https://forums.phpfreaks.com/topic/27015-one-to-many-i-think/#findComment-123541 Share on other sites More sharing options...
junglyboi Posted November 14, 2006 Author Share Posted November 14, 2006 ok this all worked great... thanks for everyone's help so far...now i've gone a step further... and on a shows' page like www.ticketstone.com/shows.php?show=61 i want the user to be able to click the band's name, and it take it to www.ticketstone.com/events.php?q=art&art=[artist_id]so from the example above, if they click on Superchick, it would take them to www.ticketstone.com/events.php?q=art&art=1005.now that's all working just great for me... here's the question...artist_id in the 'artists' table can match with any of the following in the 'shows' table... headliner_1, headliner_2, headliner_3, etc.this is the SELECT i'm using so far ($art is the artist_id passed from the URL)[code]SELECT * FROM shows,venues,zipcodes WHERE $art LIKE headliner_1 AND show_venue LIKE venue_id AND venue_zip LIKE zipcode AND show_end > NOW() ORDER BY show_start[/code]so ya get what i mean? it works if the artist is headliner_1, but i need to make it also look in headliner_2, headliner_3 and so on... but keeping the rest of the line where it says AND show_venue LIKE venue_id, etc. hope that makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/27015-one-to-many-i-think/#findComment-124695 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.