0
<html>
<form action="search_book.php" method="post">
Title:<input type="text" name="title"><br>
Author:<input type="text" name="author"><br>
Price of Book:<input type="text" name="price"><input type="radio" name="radio" id="less"><Label for="less">Less Than</label><input type="radio" name="radio" id="more"><label for ="more">More Than</label<<br>
<input type="submit" value="Search">
</form>
</html>
我已经使用了if/else if
声明和后期功能,当用户搜索或者通过在一个MySQL表中的记录标题,作者或价格(HTML表单字段) 。我的if/else,如果是基于用户一次输入一个表单字段声明:用户输入多形式fiields通过PHP来从MySQL表的相关记录
if($_POST['title']!="" && $_POST['title']!=" "){
$title=$_POST['title'];
$query=mysqli_query($con,"SELECT * from book where Title='$title'");
} else if($_POST['author']!=""&& $_POST['author']!=" "){
$title=$_POST['author'];
$query=mysqli_query($con,"SELECT * from book where Author='$author'");
} else if($_POST['price']!="" && $_POST['price']!=" "){
$title=$_POST['price'];
$query=mysqli_query($con,"SELECT * from book where Price='$price'");
}
我需要把它带到一个新的水平,现在想知道:
怎么办如果用户输入两个或三个字段而不是一个字段(例如作者和价格或作者和标题),则检索表格记录
在“price”文本字段附近,我需要添加两个单选按钮,用户检查价格低于或高于他在文本框中输入的价格
ü可以发表你的HTML也? – 2015-04-04 12:52:35
Vicky,我添加了html – Edward 2015-04-04 13:05:29
确定让我检查一下tym后我会回到你 – 2015-04-04 13:09:10