This is what I'm trying to do. I let the user to input DATEFROM and DATETO. Then when the user click the button, it will execute a query to SELECT * from my table WHERE DATEFROM BETWEEN DATETO. I don't know what's wrong. Please help.
<html>
<head></head>
<body>
<?php
<form method="POST" action="">
DATE FROM: <input type="date" name="datefrom"> TO: <input type="date" name="dateto"> <input type="submit" value="Extract excel file" name="extract"></input>
</form>
$datefrom = "datefrom";
$dateto = "dateto";
if(isset($_POST['extract'])){
mysql_connect("localhost", "root");
mysql_select_db("sample");
$myquery = "SELECT * FROM biometrics WHERE date_created BETWEEN '" . $datefrom . "' AND '" . $dateto . "ORDER BY id_biometrics";
$result = mysql_query($myquery);
echo "<table border='1'>
<tr>
<th>ID</th>
<th>Employee Number</th>
<th>Date Created</th>
<th>Time Created</th>
<th>Status</th>
</tr>";
while($data = mysql_fetch_row($result))
{
echo("<tr>
<td>$data[0]</td>
<td>$data[1]</td>
<td>$data[2]</td>
<td>$data[3]</td>
<td>$data[4]</td>
</tr>");
}
echo "</table>";
}
?>
</body>
</html>