I have a simple code that I can't get to work. I'm trying to get all the data between selected dates but it isn't working. Here are my codes:
form
<form action="selectedInvoices.php" method="POST">
<div class="row">
<div class="large-4 columns">
<label>From
<input type="text" class="datepicker" name="from" />
</label>
</div>
<div class="large-4 columns">
<label>To
<input type="text" class="datepicker" name="to" />
</label>
</div>
<div class="large-4 columns">
<button class="button" type="submit">Show Invoice</button>
</div>
</div>
</form>
selectedInvoices.php
$fromOrig = strtotime($_POST['from']);
$toOrig = strtotime($_POST['to']);
$from = date('Y-m-d', $fromOrig);
$to = date('Y-m-d', $toOrig);
$sql = mysql_query("SELECT * FROM allinvoices WHERE acc_date BETWEEN '".$from."' AND '".$to."'");
while($r = mysql_fetch_assoc($sql)) {
$drno = $r['drno'];
$name = $r['name'];
$amount = $r['amountdue'];
The data type of my acc_date field is varchar which I guess is wrong here. The format of the date when I insert is m-d-Y.
What should I do to make the code work? Thank you in advance.

STR_TO_DATE(acc_date, 'Y-m-D')Change the format to what you need.