i am trying to display an image from a database so the correct image shows up for the correct player (it should show up where i have a placeholder for the mean time) , I have been going through older articles and i cant seem to figure it out...
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "reapers";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// SELECT (whatever rows you want) FROM (your table name)
$sql = "SELECT ID, NAME, image FROM players";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
// Outputting HTML and the data from the DB. Change to $row['the name of the field you want']
echo "<div class='caption'><h3><img src='http://placehold.it/150x150' alt=''><center>" . $row['NAME'] . "</h3></div>";
}
} else {
echo "No players to show";
}
$conn->close();