I use an XML request to get all the news from the database. So far good, but I always get back only the last or first value in my loop.
function SendData($pass) :void {
if($pass) {
$host = "Database_:3360";
$username = "root";
$password = "root";
$dbname = "db";
$dbquery = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$stmt = $dbquery->prepare("SELECT * FROM tab_news ORDER BY `date` DESC");
$stmt->execute();
$count = $stmt->rowCount();
if($count === 0){
$news[] = 'Es gibt noch keine News...';
} else {
$news = $stmt->fetchAll(PDO::FETCH_ASSOC)
}
}
echo json_encode(
array(
'allowed' => $pass,
'count' => $count,
'news' => $news
)
);
}
I try it now for 1h but do not get the desired result. What is wrong ?