and one more question is possible to order it by 2 columns for example: by level and by experience.
Thanks a lot

Code: Select all
$query = "SELECT * from users";
echo "<table border=1><tr><td>Username</td><td>Gold</td></tr>";
while($player_info = mysql_fetch_assoc($query))
{
$username = $player_info['username'];
$gold = $player_info['gold'];
$other_info = $player_info['table_field_name'];
//then you want the link
//€ EDIT i forgot the table
echo "<tr><td><a href='profile.php?username='. $username . '> $username </a></td><td>$gold</td></tr>";
//this will display the links with the player username, i recommend a GET function on the profile page, so you can link easily.
}
Code: Select all
if(isset($_GET['username']))
{
$username = $_GET['username'];
$query = mysql_fetch_array(mysql_query("SELECT * from users where username='$username' "));
$username = $query['username'];
$gold = $query['gold'];
$email = $query['email'];
echo "$username 's Profile<br> Gold: $gold <br> Email: $email";
//I think it should work.. I wrote this manually without checking my profile.php so it might have any error..
//if it does just reply :D
//now just present the player info
}
Code: Select all
$sql = "SELECT id, name, level, xp FROM players ORDER BY level, experience";
$result = mysql_query($sql);
//Do error checking to make sure nothing went wrong
if (!$result) {
echo "Could not connect to database: " . mysql_error(); //remove the mysql_error() before making the game public
exit;
}
//Make sure results were returned
if (mysql_num_rows($result) == 0) {
echo "No players found in results.";
exit;
}
//Start beginning of table
echo "<table>";
echo " <tr>";
echo " <th>Name</th>";
echo " <th>Level</th>";
echo " <th>Experience</th>";
echo " </tr>";
//Loop through results and format into table with clickable links to player profiles
while ($row = mysql_fetch_assoc($result)) {
echo " <tr>";
//this next line takes a bit of piecing together. What we are doing is making a table data point that has the player name
// ...linked to a "profiles.php" page and it is sending the id along in a GET query string. Retrieve this on the profiles page
// ...and query there for the player's profile info
echo " <td><a href='profiles.php?id=".$row['id']."'>".$row['name']."</a></td>";
echo " <td>".$row['level']."</td>";
echo " <td>".$row['xp']."</td>";
echo " </tr>";
}
//Close the table
echo "</table>";