<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Php Name Generator - Project 1</title>
    <meta name="description" content="Php Name Generator - Project 1">
    <meta name="author" content="MyCatGray">
    <link rel="stylesheet" href="css/styles.css?v=1.0">
    <?php
        $random_name = "";
        $conn = mysqli_connect("localhost","root","","kodesmart");
        if(!$conn)
        {
            die("Connection Error!");
        }
        $query_random = "SELECT name FROM name_generator ORDER BY RAND() LIMIT 1";
        $result = mysqli_query($conn,$query_random);
        if(mysqli_num_rows($result) > 0)
        {
            while($row = mysqli_fetch_assoc($result))
            {
                $random_name = $row["name"];
            }
        }
        mysqli_close($conn);
    ?>
</head>
<body>
    <div id="container">
        <h1>PHP and MySQL Name Generator</h1>
        <h2 id="random_name"><?php if(!empty($random_name)){echo $random_name;} ?></h2>
        <div><form action="index.php"><input type="submit" value="Generate"></form></div>
    </div>
</body>
</html>