これまでのところ、私のJSON出力は次のようになっています
[{"dateClose":"2012-07-06","countno":"6","cumulative_sumc":"103"}],[{"dateOpen":"2012-05-29","openNo":"73","cumulative_sum":"73"}]
実際、1つの多次元配列だけで、以下のようにしたいところ
[{"dateClose":"2012-07-06","countno":"6","cumulative_sumc":"103","dateOpen":"2012-05-29","openNo":"73","cumulative_sum":"73"}]
project1[] および project[] 配列に対して array_merge,array_combine を使用してきましたが、うまくいきません。私のサンプルコードは以下です。どんな助けでも大歓迎です.Thanks.
<?php
require_once('mysql.inc.php');
$dbc =@mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME);
$x="Set @csum := 0";
$q = "
select dateClose, countno, (@csum := @csum + countno) as cumulative_sumc
from dateclose
order by dateClose";
$rx = mysqli_query($dbc, $x);
$r = mysqli_query($dbc, $q);
if (mysqli_num_rows($r) > 0) {
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
$project[] = $row;
}}
$y="Set @csum := 0";
$z = "
select dateOpen, openNo, (@csum := @csum + openNo) as cumulative_sum
from dateopen
order by dateOpen";
$rx = mysqli_query($dbc, $y);
$r = mysqli_query($dbc, $z);
if (mysqli_num_rows($r) > 0) {
while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
array_push($project, $row);
}}
echo json_encode($project);
?>