PHP/Form/Form Based Query

Материал из Web эксперт
Перейти к: навигация, поиск

Build query string based on form input

<?php
if (isset($_POST["submit"])) {
      $rowID = $_POST["id"];
      mysql_connect("mysql153.secureserver.net","wbex","password");
      mysql_select_db("wbex");
      
      $query = "SELECT * FROM Employee WHERE ID="$id"";
      $result = mysql_query($query);
      list($name,$productid,$price,$description) = mysql_fetch_row($result);
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
   <select name="id">
      <option name="">Choose a employee:</option>
      <option name="1">1</option>
      <option name="2">2</option>
      <option name="3">3</option>
   </select>
   <input type="submit" name="submit" value="Submit" />
</form>