I have two tables, one has all the information, and the other one has all the row of a particular status. I tried to join them and then select from the result of the join. How should I do it? I am very new to php.
Or is there a better way to do this. Table 1 has column (ID, Names, Contract_Left, etc), Table 2 has column (ID, RFA). Basically I just want the names with a contract left of 1 year who isn't a RFA. Table 2 only contains IDs for those who is RFA.
<?php
// Make a MySQL Connection
mysql_connect("localhost", "USERNAME", "PW") or die(mysql_error());
mysql_select_db("rzca-football_rzl") or die(mysql_error());
// Get specific results from the database
$query = "SELECT * FROM players LEFT JOIN rfa ON players.PGID = rfa.PGID UNION
SELECT * FROM players RIGHT JOIN rfa ON players.PGID = rfa.PGID WHERE players.PGID IS NULL
WHERE players.Contract_Left = '1' ORDER BY players.Team";
$result = mysql_query($query) or die(mysql_error());
?>
<div>
<table border="0" class="smallplainWithBorder" cellpadding="2" cellspacing="0" width="600">
<tr class="darkback">
<td colspan="7" valign="bottom" class="statcell"><b><h1>Pontential Free Agent In 2013</h1></b></td>
</tr>
<?php while($row = mysql_fetch_array( $result )) {
echo "<tr class='darkback'>";
echo "<td class=statcell>" . "<img src=http://rzl-football.com/files/images/icons/".$row['Team'].".gif>" . "</td>";
echo "<td class=statcell>" . "<a href=http://rzl-football.com/player.php?pgid=".$row['PGID'].">" . $row['First_Name'] . " " . $row['Last_Name'] . "</a></td>";
echo "<td class=statcell>" . $row['Pos'] . "</td>";
echo "<td class=statcell>" . $row['Age'] . "</td>";
echo "<td class=statcell>" . $row['HGT'] . "</td>";
echo "<td class=statcell>" . $row['WGT'] . "</td>";
echo "<td class=statcell>" . $row['OVR'] . "</td>";
echo "</tr>";
}
?>
</table>
</div>
Thank you very much in advance. Any pointer will help.