首頁 >php教程 >PHP源码 >【PHP】直接在页面上查询数据库,执行SQL语句

【PHP】直接在页面上查询数据库,执行SQL语句

PHP中文网
PHP中文网原創
2016-05-25 17:16:061307瀏覽

php代码:

<?php
if (isset($_POST[&#39;submit&#39;])) {
      $rowID = $_POST[&#39;id&#39;];
      mysql_connect("mysql153.secureserver.net","java2s","password");
      mysql_select_db("java2s");
      
      $query = "SELECT * FROM Employee WHERE ID=&#39;$id&#39;";
      $result = mysql_query($query);
      list($name,$productid,$price,$description) = mysql_fetch_row($result);
}

?>
<form action="<?php echo $_SERVER[&#39;PHP_SELF&#39;]; ?>" 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>

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn