samedi 13 novembre 2021

HTML form check box using SQL database values

I have project with HTML PHP and SQL database. I have design HTML input form to collect data from user and put drop down menu using PHP. I collected data from SQL database using query and those data used to drop down list and user can select those data. I have using following codes in PHP section.

$quary2 = "SELECT Name, ID FROM class ORDER BY Name";   
$results2 = mysqli_query($connection,$quary2);

while($result = mysqli_fetch_array($results2))
    {
    $Classes .= "<option value=\"{$result['Name']}\">{$result['Name']}</option>";
    }

In HTML form section I used following sample to display collected data.

<p>
    <label for=" ">Classes Are</label><br>
    <select name="Classes[]" size="3" multiple >
    <?php echo $Classes ?>
    </select>
</p>

I tried to use this process through Check boxes (Drop down list -> Check box) But I cant fix that. So, If someone can give proper way to do this it is highly appreciate.




Aucun commentaire:

Enregistrer un commentaire