php - Getting Bootstrap dropdown value to save to database and display in table -


i'm having trouble getting bootstrap ul li list store values database on click, , display them. have index page fields , dropdowns. user puts text fields , selects dropdown, when click button page refreshed , data displayed in table.

i don't want use because want style dropdown consistently.

when tested saved data, no luck unordered list.

i've searched solution , read documentation can't find information might match setup , i'm not fluent in php. here snippets. if more needed i'll provide. 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 issue seems be:

<?php      $query = mysql_query("select `id`, `prep`, `food` order 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 food(prep) value ('$prep')");         require_once header("location: ../index.php");     } else {         echo "<p>please fill out fields</p>";     } }  mysql_close($connection); 

as mistermansam said, mysqli or pdo new method.

it looks $food isn't being defined in form action query not running. may have meant type $prep:

if(isset($_post['submit'])){     $prep = $_post['prep'];     if($prep !=''){         $query = mysql_query("insert food(prep) value ('$prep')");         require_once header("location: ../index.php");     } else {         echo "<p>please fill out fields</p>";     } } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -