jedney Posted February 24, 2008 Share Posted February 24, 2008 Hello. I am trying to do some PHP scripting, to include information from 2 different tables, and I see in my PHP book how to do it, but I do not understand a few things. So, I will explain everything. I am making a web site for an online gaming team. This site includes a page called matches.php. This page includes date, time, match format, match type, map played on, opponent, score, results and a write up on the match. Various elements of the page will be clickable for details (date will be clickable to show details of the match, match format will be clickable for a list of matches in that format only, etc). One thing I want clickable in this page is the opponent. The opponent information is kept in a different table. My plan was, when I create the page in the admin section of the site, to enter a new match, it would give a list for opponents, and read the opponent names from the opponents table, and just echo the name and input it into the matches table under opponent. But, what I click the opponent name, I want it to show the details of the opponent, but also, the matches that the team had with them. How I was going to do this was like this: <?php SELECT matches.name, opponents.name FROM opponent, matches WHERE matches.name = opponent.name ?> To my knowledge, this will link the name row, in both tables. What I can't find, is when I link the opponent name, to show the details, it would be in a isset script to show something allong the lines of matches?opp=1 where 1 would equal the opponent's ID in the table. How can I pull the opponents ID from the opponents table, while still displaying information from the matches table. I'm getting lost. Jon Quote Link to comment Share on other sites More sharing options...
ucffool Posted February 24, 2008 Share Posted February 24, 2008 Remember, you can pull more information through your MySQL query than you will be showing the user directly. $query = " SELECT matches.name, opponents.name, opponents.id FROM matches, opponents WHERE matches.name = opponents.name " Quote Link to comment 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.