I have a MySQL Query with following code:
$stmt_offer = $pdo->query("SELECT * FROM `offers` WHERE `fs` = '1' ORDER BY `id` DESC LIMIT 15");
foreach ($stmt_offer as $row):
$array_s['hbid'] = $row['ang_id'];
$array_s['title'] = $row['titel'];
$array_s['size'] = $row['qm'];
$array_s['description'] = $row['beschreibung'];
endforeach;
$array_object['response'] = $array_s;
$array_offer['offer'] = $array_object;
echo json_encode($array_offer);
The Code works finde, but i get only one result back.
My Output:
{
"offer":
{
"response":
{
"hbid":"1234567",
"title":"Test",
"size":"100",
"description":"my_description"
}
}
}
What's the error in the foreach code?