-1

В моем коде выводится только один первый встречаемый элемент из бд с определенным id_user, а мне нужно вывести все элементы с данным id_user через json.

$query = "Select * from Historybalans where id_user = '$id_user'";
$result = mysqli_query($this->connection, $query);
$row = mysqli_fetch_assoc($result);
$user_text_count = $row['text_count'];
$user_text_info = $row['text_info']; 
$json['text_count'] = $user_text_count;
$json['text_info'] = $user_text_info;

1 ответ 1

-1

Решение:

while ($row = $result->fetch_assoc()) {
    $user_text_count = $row['text_count'];
    $user_text_info = $row['text_info']; 
    $json['text_count'] = $user_text_count;
    $json['text_info'] = $user_text_info;
    echo json_encode($json);
}

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.