Associate
- Joined
- 19 Mar 2005
- Posts
- 569
Cannot get this list of players here which have been created by querying the users table in players.php. Just cannot get playerDetails.php to display the player that I have just clicked in players.php. Whenever I click on a player it takes me to playerDetails.php but I get the message no such username. Just wondering where I am going wrong?
players.php
playerDetails.php
players.php
PHP:
<?php
include 'library/config.php';
include 'library/opendb.php';
$p2=mysql_query("SELECT users.username, users.playerName FROM users") or die(mysql_error());
echo "<ol>";
while($row=mysql_fetch_assoc($p2)) {
echo "<li><a href=\"playerDetails.php?$row[username]=$row[username]\">$row[playerName]</a></li>\r\n";
}
echo "</ol>";
include 'library/closedb.php';
?>
playerDetails.php
PHP:
<?php
include 'library/config.php';
include 'library/opendb.php';
$username = $_REQUEST['username'];
//this bunch of code will get you the id of the player you are looking for
//The following code will get the details from mysql table
$sql = "SELECT * FROM users WHERE username='$username'";
$query = mysql_query($sql);
if (mysql_num_rows($query) > 0) {
$row = mysql_fetch_array($query);
$name = $row['playerName'];
$town = $row['town'];
$email = $row['email'];
}
else { echo "No Such username"; exit; }
echo "Player Name: $name <br> Town: $town <br> Email: $email";
?>