I'm having trouble getting a Bootstrap ul li list to store values to a database on click, and then display them. I have my index page with some fields and then dropdowns. The user puts text into the fields and selects from the dropdown, when you click the button the page is refreshed and the data is displayed in a table.
I don't want to use because I want to style the dropdown consistently.
When I tested it with it saved the data, but no luck with an unordered list.
I've searched for the solution to this and read documentation but can't find any information that might match my setup and I'm not fluent in PHP. Here are some snippets. If more is needed I'll provide. Thanks for reading.
Form:
<form action="parts/insert.php" method="post" role="form">
<select name="prep" id="prep">
<option value="">Preparation</option>
<option value="0 - 10 mins" >0 - 10 minutes</option>
<option value="11 - 30 mins">11 - 30 minutes</option>
<option value="One hour +">One hour +</option>
</select>
<input class="submit btn btn-block btn-lg btn-primary" name="submit" type="submit" value="Add" />
</form>
Where the issue seems to be:
<?php
$query = mysql_query("SELECT `id`, `prep`, FROM `food` ORDER BY food ASC");
while($row = mysql_fetch_array($query)) {
?>
<tr>
<td><?php echo $row['prep']; ?></td>
</tr>
insert.php:
$connection = mysql_connect("hostname", "username", "password");
$db = mysql_select_db("databasename", $connection);
if(isset($_POST['submit'])){
$prep = $_POST['prep'];
if($food !=''){
$query = mysql_query("insert into food(prep) value ('$prep')");
require_once header("Location: ../index.php");
} else {
echo "<p>Please fill out all fields</p>";
}
}
mysql_close($connection);