我有我的mysqli查詢:如何只顯示json中的值而不是鍵:值對?
$fetchTransactions = "SELECT * FROM transaction WHERE client_id = '$client_id'";
$result = $mysqli->query($fetchTransactions);
$data = array();
$data = $result->fetch_all(MYSQLI_ASSOC);
echo json_encode($data);
它返回JSON作爲:
[{"transaction_id":"1","client_id":"2","total_price":"100.70","creation_date":"2015-10-18 03:00:00","unique_hash":"ABCDEF"},
{"transaction_id":"2","client_id":"2","total_price":"88.20","creation_date":"2015-10-18 04:00:00","unique_hash":"GHIJK"}]
取而代之的是,我想在這裏呈現在表單中的數據:
{
"data": [
[
"1",
"2",
"100.70",
"2015-10-18 03:00:00",
"ABCDEF"
],
[
"2",
"2",
"88.20",
"2015-10-18 03:00:00",
"GHIJK"
],
,因爲我需要這個json格式來提供從這裏取得的數據表:https://datatables.net/examples/data_sources/ajax.html
你能幫我嗎?