Associate
- Joined
- 19 Mar 2005
- Posts
- 569
Hi there,
Got a simple problem, i have two tables one for players and one for playerRankings and from these table i want to select the followng fields:
players: playerID, playerName
playerRankings: pRankingsID, pRplayerID, pRankingScore, pPrevRankingScore
So i devised this SQL query to pick them up
I think this is correct, if not could you tell me whats wrong with it.
I then tried to enumerate this in php to try and get it to display the ranking list with the points and player names beside them and I cannot do this. So I would like some help in how to fix this. My code is below it would be great if someone could tell me where I am going wrong and how to fix it.
Got a simple problem, i have two tables one for players and one for playerRankings and from these table i want to select the followng fields:
players: playerID, playerName
playerRankings: pRankingsID, pRplayerID, pRankingScore, pPrevRankingScore
So i devised this SQL query to pick them up
Code:
SELECT playerRankings.pRankingsID, playerRankings.pRplayerID, playerRankings.pRankingScore, playerRankings.pPrevRankingScore, players.playerID, players.playerName
FROM playerRankings, players
WHERE (playerRankings.pRankingsID = players.playerID)
I think this is correct, if not could you tell me whats wrong with it.
I then tried to enumerate this in php to try and get it to display the ranking list with the points and player names beside them and I cannot do this. So I would like some help in how to fix this. My code is below it would be great if someone could tell me where I am going wrong and how to fix it.
PHP:
<?php
require('db_connect.php'); // database connect script.
?>
<?php
$query = "SELECT playerRankings.pRankingsID, playerRankings.pRplayerID, playerRankings.pRankingScore, playerRankings.pPrevRankingScore, players.playerID, players.playerName
FROM playerRankings, players
WHERE (playerRankings.pRankingsID = players.playerID)";
$result = mysql_query($query) or die('Error : ' . mysql_error());
if (mysql_num_rows($result) == 0) {
//No rows
} else {
//Start enumerating
while ($row = mysql_fetch_object($result)) {
print "<div>" .
"<p>" . $row["pPrevRankingScore"] . "</p>" .
"<p>" . $row["playerID"] . "</p>" .
"<p>" . $row["playerName"] . "</p>" .
"<p>" . $row["pRankingsID"] . "</p>" .
"<p>" . $row["pRankingScore"] . "</p>" .
"</div>";
}
}
echo $pPrevRankingScore;
echo $playerID;
echo $playerName;
echo $pRankingsID;
echo $pRankingScore;
$db_object->disconnect();
?>