I am trying to return part of a table that are between two dates but the entire table keeps getting returned. Not just the values between two dates. Can you tell me what I am doing wrong with my code below?
$result = mysql_query("SELECT Name, DateTime, FROM names");
$sorting = mysql_query("WHERE DateTime between '2012-12-12 17:09:00' AND '2012-12-12 17:06:00'");
while($row = mysql_fetch_array($result,$sorting))
{
$output[] = $row;
}
print(json_encode($output));
mysql_close($con);
There are a couple syntax errors, and really you should build the complete query before sending it to the mysql_query() function: