分享一个php实例,构造基于表单的一个查询字符串。
代码:
<?php /** * 根据选择的表单,构造 查询字符串 * by www.jb200.com */ if (isset($_POST['submit'])) { $rowID = $_POST['id']; mysql_connect("192.168.10.10","user","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="">请选择一个雇员:</option> <option name="1">1</option> <option name="2">2</option> <option name="3">3</option> </select> <input type="submit" name="submit" value="确认提交" /> </form>