php - How to get a value of a select input tag with options taken from a database using POST method? -


<form method="post" action="<?php echo htmlspecialchars($_server["php_self"]);?>">     <select name="doctor">     <?php      $con = mysqli_connect("---","---","---","---") or die("can't connect database.");     $sql = mysqli_query($con, "select title, name, lastname physician");     while ($row = $sql->fetch_assoc()){     echo "<option value=\"doctor1\">" . $row['title'].' '.$row['name'].' '.$row['lastname'] . "</option>";     }      ?>     </select>     &nbsp;<input type='submit' value="filter"><br> </form> 

above form created. used post method. form has select input tag , it's options taken database. when form submitted need access value selected user using $_post['doctor'] function. doesn't give me value. can me?

if id each entry in "physician" table stored in column "physicianid", should try following code snippet:

<form method="post" action="<?php echo htmlspecialchars($_server["php_self"]);?>">     <select name="doctor">         <?php              $con = mysqli_connect("---","---","---","---") or die("can't connect database.");             $sql = mysqli_query($con, "select physicianid, title, name, lastname physician");             while ($row = $sql->fetch_assoc()){                 echo '<option value="'.$row['physicianid'].'">'.$row['title'].' '.$row['name'].' '.$row['lastname'].'</option>';             }         ?>     </select>     &nbsp;<input type='submit' value="filter"><br> </form> 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -