FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


MySQL JOIN Question





fizzo
I have this Page that Gets the TEAM field Number to show the datas coming from Player Table the Team.php page is the page were the datas will be showed.. I also make a Table Teams that has the TEAM field number same as the TEAM on the Player Table...

What I want to do is to get the TEAM Field Number from Player table and show the data's to Team.php and also SHOW the Images that is stored from table Teams using the TEAM field number as it is the same for both tables... Here is the codes from the Team.php were I already solved getting the Informations or datas from the database using the TEAM Number...

Code:
opentable("WBA l ");
$con = mysql_connect("localhost","********","******");
mysql_select_db('DATABASENAME');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$TEAM = $_GET['TEAM'];
$team = mysql_query("SELECT * FROM Players WHERE TEAM = '$TEAM' ORDER BY ROSTERPOS");
echo"<table border='0'><br><br><img border=0 src=http://nclballers.com/files/images/det_banner.jpg width=595 height=24><br><img border=0 src=http://nclballers.com/files/images/det_logo.gif><b><font size=6>TEAM ROSTER</font>
<tr>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1 face=Verdana color=white></th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1 face=Verdana color=white>PLAYER</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1 face=Verdana  color=white >YRS EXP</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>OVRLL</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>RNG</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>FG</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>3PT</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>FT</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DNK</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>STL</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>BLK</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>OR</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DR</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>BH</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>OA</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DA</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>SPD</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>QCK</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>JMP</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>DRB</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>STG</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>HRD</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>IS</th>
<th style=border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium bgcolor=black><font size=1  color=white face=Verdana>PRI</th>
</tr></font>";
while($row = mysql_fetch_array($team))
   {
echo "<tr>";
  echo "<td bgcolor=#666666>" .$row['ROSTERPOS']. "</td>";
  echo "<td>"."<b>"."<a href=http://www.ayc.frih.net/WBA/PlayerPage.php?PLAYERID=".$row['PLAYERID'].">".$row['FNAME'] . " " . $row['NAME']."</a>" ."</b>"."<br>". "<b>#"."</b>".$row['NUMBER']." "."[" .$row['POSITION'].",".$row['POSITION2']."]"."</td>";
  echo "<td bgcolor=#666666>" . $row['YEARSEXP'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['OVERALLRTG'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['DSHOOTRANG'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['FGPBASE'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['THREEPTBAS'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['FTPBASE'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['DNKABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['STLABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['BLKABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['OREABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['DREABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['BALABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['OFFABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['DEFABILITY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['SPEED'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['QUICK'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['JUMP'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['DRIBBLE'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['DSTRENGTH'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['DHARDY'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['INSIDESC'] . "</td>";
  echo "<td bgcolor=#666666>" . $row['PRIMACY'] . "</td>";
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
closetable();



Could I use a Join for this but if I do use Join how will I code it when I got this one...
Code:
$TEAM = $_GET['TEAM'];
$team = mysql_query("SELECT * FROM Players WHERE TEAM = '$TEAM' ORDER BY ROSTERPOS");


Thanks hope you could help me... have a nice day! Wink
Fire Boar
JOINs are for linking two tables together. You're not using more than one table so the answer is no.
fizzo
Ok. Thanks but how can I get the Data from Table TEAMS while Im connected with Table PLAYERS.

I want to get Datas or Infos from Table PLAYERS and show it on my Page and at the same time also get Datas to Table TEAMS and show it also on same page... Thanks
Fire Boar
Oh, you mean something like...:

Code:
$query = "SELECT p.*, t.* FROM Players AS p LEFT JOIN teams AS t ON (t.Teamname='".$TEAM."') WHERE p.TEAM='".$TEAM."'";


This?
Related topics
mysql connection question
php admin and mysql admin console
Question about MySQL!
PHP, MySQL...
PHP Book (Php and Mysql for Dynamic Web Sites)
PHPBB MYSQL Database Question.
PHP MySQL Commands Question
how to install phpbb forum?
Project to join - php,mysql??
Question about a php and mysql script.
[Edit] mySQL Count
MySQL and PHP Question
Mysql 101 question
mysql query based on 2 fields using 3 different tables
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.