I have a form where the user can search for a date range, so far so good. If it searches only for a date, how can I do this directly in sql or even in php?!
Any suggestions?
I have a form where the user can search for a date range, so far so good. If it searches only for a date, how can I do this directly in sql or even in php?!
Any suggestions?
Simply put:
$data2 = empty($data2) ? $data1 : $data2;
$sql = "SELECT ... BETWEEN $data1 AND $data2;";
If the second date is done, it receives the value of the first date if not the value itself, you can use other values if the second date is empty, for example, "NOW()"