<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>
I have used an if/else if
statement and post function when user searches either by title, author or price(html form fields) for records in a mysql table. My if/else if statement that is based on user inputting one form field at a time:
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'");
}
I need to take it to the next level now and want to know:
How do I retrieve table records if the user inputs two or three fields and not just one(eg. author and price or author and title)
Near the 'price' text field I need to add two radio buttons which will allow the user to check less than or more than the price he inputs in the textbox for price