this is my code

$sql = "SELECT * FROM `sale_history` WHERE `date` BETWEEN :fromdate AND :todate";
    $stmt = $PDO->prepare($sql);
    $stmt->bindParam(':fromdate', $_POST['fromdate'], PDO::PARAM_STR);
    $stmt->bindParam(':todate', $_POST['todate'], PDO::PARAM_STR);
    $total = $stmt->rowCount();
    while ($row = $stmt->fetchObject()) {
        echo "$row->date"; 
        echo "$row->product"; 
        echo "$row->username"; 
        echo "$row->quantity";

but its not working, where is the mistake i did?

For some reason the C++ like bindParam is looking better to most than the simpler question mark. For some reason you use fetchObject although it isn't really an object but an anonymous one. For some reason you echo it with double quotes. None of those would be an error. But the "not working" could mean a lot , what do you mean ? Do you get an error ? What this error is ? Is it simply not echoing anything ? Also provide us what the $PDO is .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.