12.02.2014, 13:56
Okay so i am trying to display the data of the player that has been clicked. Its almost working but for some reason it always just displays the name of the first person in the database. This is the code:
Does anyone know why it always displays the first person in database?
PHP код:
<?php
global $mysql; // we are going to use mysql right? :P
if (isset($_GET['Name'])) {
$page = mysqli_escape_string($mysql, (int)$_GET['Name']); // let's make sure that we just get the integer and not a attempt to do sql injection
$query = mysqli_query($mysql, "SELECT * FROM `Users` WHERE `Name` = {$page}");
if(!mysqli_num_rows($query)) { // if the club requested does not exists...
header("Location: ?p=Topscores");
exit;
}
$data = mysqli_fetch_array($query); // $data['ROW_NAME'];
echo $data['Name'];
} else { ?>
<h1>Top 20 players with the highest score</h1>
<table width="960" border=1 frame=void rules=rows>
<tr>
<td>Pos.</td>
<td>Name</td>
<td>Score</td>
<td>Truckloads</td>
<td>Convoy score</td>
<tr>
<?php
$Count = 1;
$query = mysqli_query($mysql, "SELECT * FROM `Users` ORDER BY `Score` DESC LIMIT 0,100");
while($row = mysqli_fetch_array($query)) {
echo '
<tr>
<td>'.$Count.'</td>
<td><a href="?p=Topscores&Name='.$row['Name'].'">'.$row["Name"].'</a></td>
<td>'.$row["Score"].'</td>
<td>'.$row["TJobs"].'</td>
<td>'.$row["CJobs"].'</td>
</tr> ';
$Count++; } ?>
</table>
<?php } ?>
<br><br><br>