lecture 39

 <?php

$server = "localhost";
$user = "root";
$pass = "";
$db = "mydb";


$conn = mysqli_connect($server, $user, $pass, $db);

?>

<!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>Document</title>
</head>

<body>

    <?php
    // $query = "SELECT name, address FROM  user";
    $query = "SELECT * FROM  user";


    $result = mysqli_query($conn, $query);


    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            // print_r($row);
            echo "<table border='1' cellspacing='0' cellpadding='10'>
            <tr>
            <td>"
                . $row['name'] .
                " </td>
           <td>"
                . $row['address'] .
                " </td>
                <td>"
                . $row['email'] .
                " </td>
            </tr>
            </table>";
        }
    } else {
        echo "No data";
    }



    ?>

</body>

</html>

Comments