-1

i'm trying to use a variable that i get it from an html form here is the html code

<input type="date" name="begin_date">
<input type="date" name="end_date">

and i will enter something like this 2015-6-20 00:00:00 in the text fields. then i want to use those variables in mysql where clause like below:

->where('o.invoice_date >= $begin_date AND o.invoice_date < $end_date');

but somehow it doesn't work...
when i do it like

->where('o.invoice_date >= "2015-6-20 00:00:00" AND o.invoice_date < "2015-6-20 00:00:00"');

it works fine but not with variables.. what's the problem?

1 Answers1

1

replace single quotes with double

not

->where('o.invoice_date >= $begin_date AND o.invoice_date < $end_date');

but

->where("o.invoice_date >= $begin_date AND o.invoice_date < $end_date");

also $begin_date should be defined like $begin_date = $_POST['begin_date']

$end_date in same manner

M0rtiis
  • 3,676
  • 1
  • 15
  • 22