I can receive a variable from a user in a form and send it to another page. There I get the variable and search it in the database. But when I try to allow the user to search multiple variables at the same time (that is, they can search for one or more items), I have a problem and I can not write a query in such a way that when the user Enter the item and also search for when more than one item has been entered. This is my html document
<form name="search-class-form" id="search-class-form" action="search.php" method="post">
<div class="rafig-margin">
<label for="class_id">calss id: </label>
<input type="number" name="class_id" id="class_id"><br>
</div>
<div class="rafig-margin">
<label for="className">teacher name: </label>
<input type="text" name="name" id="className"/>
</div>
<div class="rafig-margin">
<label for="grade">level: </label>
<input type="number" name="paye" id="grade" min="1" max="13"/>
</div>
<input type="hidden" name="student_id" value="<?= $_GET['id'] ?>"/>
<div class="rafig-margin">
<button class="rafig-button" style="float: left" type="submit" id="search-class">جستجو کن</button>
</div>
</form>
And this is my php page:
<?php
$condition ="";
if(isset($_POST['id'])&&!empty($_POST['id']))
{$id = $_POST['id'];
$condition .= "WHERE id=".$_POST['id'];
}
if(isset($_POST['name'])&&!empty($_POST['name']))
{$name = $_POST['name'];
$condition .= " WHERE id=".$_POST['name'];
}
if(isset($_POST['paye'])&&!empty($_POST['paye']))
{$level = $_POST['paye'];
$condition .= " WHERE paye=".$_POST['paye'];
}
$student_id = $_POST['student_id'];
include_once ("../classes/conect.php");
$query = "SELECT * FROM calss ".$condition;
I know how to continue