I'm getting this error:
Notice: Undefined variable: displaydata in C:\laragon\www\tasks\index.php on line 17
This is my index.php:
<?php
include('php/functions.php');
?>
<!doctype html>
<html ng-app>
<head>
<title>Opgaver</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
</head>
<body>
</body>
</html>
<?php
while($row = $displaydata->fetch(PDO::FETCH_ASSOC)) {
if($row['created'] < date('Y-m-d')) {
echo 'TEST';
}
}
?>
And this is my functions.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require('php/database.php');
class Functions {
public function DisplayData() {
try{
$db = getDB();
$displaydata = $db->prepare('SELECT * FROM tasks ORDER BY created ASC');
$displaydata->execute();
$data = $displaydata->fetch(PDO::FETCH_OBJ);
return $data;
}
catch(PDOException $e) {
echo '{"error":{"text":'. $e->getMessage() .'}}';
}
}
}
?>
I have already defined the public function, I don't see the problem.