欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

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

程序员文章站 2022-06-16 16:40:56
...
php代码:
<?php
if (isset($_POST['submit'])) {
      $rowID = $_POST['id'];
      mysql_connect("mysql153.secureserver.net","java2s","password");
      mysql_select_db("java2s");
      
      $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>