well the code looks good so far 😉
but to extract the values out of the db you nn=eed to use something like this
note this is just an example to get you started don't just insert this into your code you must form and manipulate it to your needs
$link_id = db_connect('your db name');
$result = mysql_query("SELECT * FROM whatever", $link_id);
for($i = mysql_num_rows($result)-1; $i >= 0; $i--)
{
mysql_data_seek(result, $i);
$query_data = mysql_fetch_array($result);
echo "<input name=whatever you want type=whatever you need value='$query_data[the index for the value you want];'>
}
hope that will help you if not let me know 🙂