Цель — извлечь данные JSON и их сумму и построить массив в цикле foreach.
Вот мой код:
Код: Выделить всё
$sql = "SELECT `Amount`, `NewObject` FROM `mb_cart` WHERE `MyID` = '$id'";
$data_main = $db->query($sql);
Код: Выделить всё
foreach ($data_main as $transaction_main) {
$json_decoded = json_decode($transaction_main);
$cart = array('Amount' => $amount, 'CodeType' => $json_decoded->data->Type->data->codeType, 'Name' => $json_decoded->data->Name, 'SiteName' => $json_decoded->data->SiteName);
}
Подробнее здесь: https://stackoverflow.com/questions/929 ... tiple-rows