user3260242
user3260242

Reputation: 1

mysql statement error .No result

Alright so right now i am generating a report from submit button and it has two input type that are from and to but the thing is i want from and too date and the result isnt showing up from the database

    $order_time=$_POST["datefrom"];
    $order_time=$_POST["dateto"];

    $query = "SELECT * FROM ss_orders where order_time='".$order_time."' limit 60";

Thats my above code , so is it possible to use between in that above query ? and also my data type in the database of order_time is datetime ? so why i am not getting any result ?

Thanks in advance :) Help will be appreciated :)

Upvotes: 0

Views: 61

Answers (2)

Steve Bals
Steve Bals

Reputation: 1989

$order_time=$_POST["datefrom"];
$s= date("Y-m-d", strtotime($order_time)); 
$order_timeto=$_POST["dateto"];
$e= date("Y-m-d", strtotime($order_timeto)); 

$query = "SELECT * FROM ss_orders where datetime<=$s and datetime>=$e";

Upvotes: 2

ɹɐqʞɐ zoɹǝɟ
ɹɐqʞɐ zoɹǝɟ

Reputation: 4370

as a programmer you should check and debug your code in all possible ways,you can print what are the values these variables having and you cal also print the query so you can know what is the actual query executing.

 $fromdate=$_POST["datefrom"];
 $todate=$_POST["dateto"];

    $query = "SELECT * FROM ss_orders where datetime<='$todate' and datetime>='$fromdate' limit 60";

and PDO/MYsqli for security

Upvotes: 0

Related Questions