I have a search field with 3 fields (2 field for date range and 1 field for person). I would like if I select the person, then the data based on this person to appear on the screen. Same as I am using the while loop below.
When I select the date range, only the data for this date range to appear on the screen. I am able to do that using the following query.
$startDate = $_POST['startDate'];
$endDate = $_POST['endDate'];
$employer = $_POST['employer'];
$sql = "
SELECT *
FROM jobs
WHERE employer_id = '$employer'
OR (endDate BETWEEN '$startDate' AND '$endDate')
";
$res = mysqli_query($db, $sql) or die(mysqli_error($db));
I would also want if I select both the date range and the person field, then I would like the data for both of them to appear on the screen with the while loop shown below.
I want this to be achieved using the query above, but I do not have a solution.
Then, I extract all data in a while cycle:
while($row = mysqli_fetch_assoc($res))
{
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$title = $row['job_title'];
$date = $row['endDate'];
}