Reputation: 21
Hi I want to search the items present in the table users. The code I wrote is
$fromdate = date("Y-m-d H:i:s", strtotime($_POST['fromdate']));
$todate = date("Y-m-d H:i:s", strtotime($_POST['todate']));
$s="SELECT * FROM logs WHERE dt BETWEEN $fromdate AND $todate ORDER BY dt DESC ";
$x = mysql_query($s);
But the output is not showing. Please someone help me.
Upvotes: 0
Views: 2512
Reputation: 21437
Need to apply quotes around '$fromdate'
and '$todate'
as
$s="SELECT * FROM logs WHERE dt BETWEEN '$fromdate' AND '$todate' ORDER BY dt DESC ";
Upvotes: 1
Reputation: 29
$fromdate = strtotime($_POST['fromdate']);
$todate = strtotime($_POST['todate']);
$query="SELECT * FROM logs WHERE UNIX_TIMESTAMP(dt) BETWEEN $fromdate AND $todate ORDER BY dt DESC ";
Upvotes: 0