1

I am attempting to retrieve a list of all future dates that have been inserted into my MYSQL table.

Example: I have inserted the values 8-16-14, 8-27-16, 8-17-17. The issue is that the below code returns all of the values and not just the future ones.

Any ideas why this is not working?

public function getUpcomingDate($id) {
		 
$date = date('m-d-y');
		
        $stmt = $this->conn->prepare("SELECT * FROM roles WHERE id = ? AND item_date > '$date'");
        $stmt->bind_param("i", $id);
        $stmt->execute();
		$user = $stmt->get_result();
		$row_count = $user->num_rows;
		while ($row = $user->fetch_assoc()) {
			$data[] = $row;
		}

        $stmt->close();
		
		if($data) {
            return $data;
        } else {
            return false;
        }
    }

1
  • MySQL might be expecting a specific format when comparing dates... Check out str_to_date() Commented Aug 17, 2016 at 19:49

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.