How can the SQL query in mitspieler_info.php be modified to display data for a specific player based on the id passed through the URL?
To display data for a specific player based on the id passed through the URL, you can modify the SQL query in mitspieler_info.php to include a WHERE clause that filters the results based on the player id. You can retrieve the player id from the URL using $_GET['id'] and then use it in the query to fetch the data for that specific player.
<?php
include 'db_connection.php';
if(isset($_GET['id'])) {
$player_id = $_GET['id'];
$sql = "SELECT * FROM spieler WHERE id = $player_id";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "Name: " . $row["name"]. " - Position: " . $row["position"]. "<br>";
}
} else {
echo "0 results";
}
} else {
echo "Player id not provided in the URL";
}
$conn->close();
?>