How to Display MySQL data as a checklist on HTML website?
<p>It's not a very complex problem but I've been stuck for the past few days and can't seem to figure it out. I have a database called "major_degrees" and I want to fetch all the majors from the table called "majors" in this database and then display it as a checklist on my website using PHP and HTML.</p>

<p>I believe the fault is somewhere in my while loop.. it is printing the data as text but I want it as a checklist so I can check off the options I want and save them.</p>

<p>Here is the PHP code I have so far:</p>

<pre><code>&lt;?php

    $username = "root";
    $password = "";
    $hostname = "localhost";

    $dbname = "major_degrees";
    $str='';

    // Create connection
    $conn = new mysqli($hostname, $username, $password, $dbname);

    // Check connection
    if ($conn-&gt;connect_error) {
        die("Connection failed: " . $conn-&gt;connect_error);
    } 

    $sql = "SELECT degree_name FROM majors";
    $result = $conn-&gt;query($sql);

    if ($result-&gt;num_rows &gt; 0) {
        // output data of each row
        while($row = $result-&gt;fetch_assoc()) {
            echo $row['degree_name'];
            echo "&lt;br/&gt;";
        }
        return $str;
    } 
    $conn-&gt;close();


?&gt;   
</code></pre>