Lab 9
Lab 9
Lab 9
<!DOCTYPE html>
<html>
<body>
<?php
$user = 'root';
$password = '';
$dbname = "myDB4";
// Create connection
$conn = new mysqli('127.0.0.1', $user, $password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($result->num_rows > 0) {
// output data of each row
$conn->close();
?>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
}
<?php
$user = 'root';
$password = '';
$dbname = "myDB4";
// Create connection
$conn = new mysqli('127.0.0.1', $user, $password,$dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($result->num_rows > 0) {
echo "<table><tr><th>ID</th><th>Name</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["id"]. "</td><td>" .
$row["firstname"]. " " . $row["lastname"]. "</td></tr>";
}
echo "</table>";
$conn->close();
?>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<?php
Eng. Areeg Ahmed Bukair
Web Applications Development
B3IT
$user = 'root';
$password = '';
$dbname = "myDB4";
// Create connection
// Check connection
if ($conn->connect_error) {
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<br> id: ". $row["id"]. " - Name: ". $row["firstname"]. " " . $row["lastname"] . "<br>";
} else {
$conn->close();
?>
</body>
</html>
<?php
$user = 'root';
$password = '';
$dbname = "myDB4";
// Create connection
// Check connection
if ($conn->connect_error) {
} else {
$conn->close();
?>
Eng. Areeg Ahmed Bukair
Web Applications Development
B3IT