到目前为止,我的 JSON 输出是这样的
[{"dateClose":"2012-07-06","countno":"6","cumulative_sumc":"103"}],[{"dateOpen":"2012-05-29","openNo":"73","cumulative_sum":"73"}]
实际上我希望它像下面一样,只是在一个多维数组中
[{"dateClose":"2012-07-06","countno":"6","cumulative_sumc":"103","dateOpen":"2012-05-29","openNo":"73","cumulative_sum":"73"}]
我一直在对 project1[] 和 project[] 数组使用 array_merge,array_combine,但没有运气。我的示例代码如下。任何帮助将不胜感激。谢谢。
<?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);
?>