Inserting values from Mysql to an HTML form

I am looking for a way to insert values from Mysql to HTML form. I searched the internet but all I can find is how to insert data from a form to Mysql. How can achieve this? Can anybody help me, please? thanks.

This is how my form looks like:

 [code] <form id="form" name="form" method="post" action="">
         <label>                
                <input type="checkbox" name="SelectAll" class="all" />All</label><label>
                <input type="checkbox" name="Nissan" class="selector" />Nissan</label><label>
                <input type="checkbox" name="Toyota" class="selector" />Toyota</label><label>
                <input type="checkbox" name="Mercedes" class="selector" />Mercedes</label><label>
                <input type="checkbox" name="BMW" class="selector" />BMW</label><label>
                <input type="checkbox" name="Cadillac" class="selector" />Cadillac</label><label>
                <input type="checkbox" name="Chevrolet" class="selector" />Chevrolet</label>
[/code]

What I need is to insert the car brands from the mysql database automatically. So have rows of car brands on the data table and from these rows, the values will be fetched and inserted.

This is what I came up with so far:

[code]<?php
include (“config.php”);

$sql = “SELECT ID, Brand1, Brand2, Brand3, Brand4, Brand5, Brand6 FROM BrandDb”;
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc())
{

         <form id="form" name="form" method="post" action="">
         <label>                
                <input type="checkbox" name="SelectAll" class="all" />All</label><label>
                <input type="checkbox" name="Nissan" class="selector" />Nissan</label><label>
                <input type="checkbox" name="Toyota" class="selector" />Toyota</label><label>
                <input type="checkbox" name="Mercedes" class="selector" />Mercedes</label><label>
                <input type="checkbox" name="BMW" class="selector" />BMW</label><label>
                <input type="checkbox" name="Cadillac" class="selector" />Cadillac</label><label>
                <input type="checkbox" name="Chevrolet" class="selector" />Chevrolet</label>

} else { echo “0 results”; }
$conn->close();
?>
[/code]

First off,

SELECT ID, Brand1, Brand2, Brand3, Brand4, Brand5, Brand6 FROM BrandDb

shows a HORRIBLE data model.

You are just trying to pull data from the database to show them in a form?

Thanks for your answer. I am a new to php and mysql. This is a sample database that I created. When I finish this project, I would like to apply it to some real data later.

Refer to my answer on the other forum you cross posted this to.

Sponsor our Newsletter | Privacy Policy | Terms of Service