I am facing one issue while issuing below query. I am not sure what am i doing wrong?
$start= date("y-m-d", strtotime($start));
$end= date("y-m-d", strtotime($end));
// $start = '2016-03-03';
// $end= '2016-04-04';
if($jobtitle == ''){
$jobtitle = true;
}
if($start == '' or $end == ''){
$start = true;
$end = true;
}
$result = $mysqli->prepare("SELECT *
FROM postdata
where id = ?
and title = ?
and (date between ? and ?)
order by date desc");
$result ->bind_param("isss", $id, $title, $start, $end);
$result->execute();
Actually i have a form with 3 fields. 1 title and others 2 are start and end for date.
If user either enter value in title or put start and end date in the form. User can also put values in both filed. Once data is submitted by user then i want to perform search in database.
Please advise why my query is not working.
= is assignmentand== or ===is an equality test.title = '%%'says the content of thetitlecolumn must contain%%and only%%. You are not using a LIKE and that is the only syntax that responds to%characterstrueis not going to help you either