<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Favourite Actors</title>
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "actor";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
// if ($conn->connect_error) {
// die("Connection failed: " . $conn->connect_error);
// }
// echo "Connected successfully";
$sql = "SELECT name, image, country FROM actor";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
?>
<h1>Name : <?php echo $row["name"]; ?></h1>
<h2>Country : <?php echo $row["country"]; ?></h2>
<img src="<?php echo $row["image"]; ?>" alt="" srcset="" width="15%">
<?php
}
}
?>
</body>
</html>
Related