0

I have transaction_date in tbl_transaction table. I want to show all the transaction of the customer depends on the date start and date end. I check if it’s work and search for a previous month until this month but I get an empty table with undefined first name and last name you can see the image below. How can I do it if I only one transaction_date in my table?

 public function searchEndAndStartDate() {
     $date_start = date('Y-m-d', strtotime($transaction_date));
     $date_end = date('Y-m-d', strtotime($transaction_date));

    $sql = "SELECT tbl_transaction_details.details_id, 
 tbl_medicine.medicine_name, tbl_transaction_details.quantity, 
 tbl_transaction_details.price, tbl_transaction.transaction_date, 
 tbl_transaction_details.total_price, tbl_user.first_name, 
 tbl_user.last_name FROM tbl_transaction_details INNER JOIN 
 tbl_transaction ON tbl_transaction_details.transaction_id = 
 tbl_transaction.transaction_id INNER JOIN tbl_user ON 
 tbl_transaction.user_id = tbl_user.user_id INNER JOIN tbl_medicine ON 
 tbl_transaction_details.medicine_id = tbl_medicine.medicine_id WHERE 
 transaction_id > :transaction_id AND transaction_date 
 BETWEEN :date_start AND :date_end";

    $stmt = $this->connection->prepare($sql);
    $stmt->execute([
        ":date_start" => $date_start,
        ":date_end" => $date_end
    ]);
    return $stmt->fetchAll();
}

Vue JS methods

 searchEndAndStartDate : function() {
    axios({
        method : "GET",
        url : this.urlRoot + "gulod/search_date.php?keyword=",
        params : {
            keyword : this.start_date,
            keyword : this.end_date
        }
    }).then(function (response){
        vm.gulod_transaction_details = response.data;
        console.log(response);
    });
},
Phil
  • 157,677
  • 23
  • 242
  • 245
Bayanihan 4
  • 201
  • 2
  • 13
  • You appear to be missing a parameter for `:transaction_id`. PDO would be throwing an exception if you were configured to see it. See [How to get useful error messages in PHP?](https://stackoverflow.com/a/52324601/283366) – Phil May 17 '19 at 03:56
  • Also, `$transaction_date` is not defined in your `searchEndAndStartDate()` method – Phil May 17 '19 at 04:37
  • @Phil how does this question duplicate? You didn't give the exact source for my question. I want to display all the data between the start and end date depending on the user input. You just give how to get useful error – Bayanihan 4 May 17 '19 at 05:10
  • Now you can fix the errors and get results from your script. If you still have problems after that, feel free to open a new question but I think you'll get there on your own. – Phil May 17 '19 at 05:28
  • Also, closing as a duplicate doesn't necessarily mean the questions are the same. It's more about the answers. – Phil May 17 '19 at 05:31

0 Answers0