Dear Fellow Webmaster,
I have a question about adding data json
[{“TotalRows”:5,”TopID”:null,
“Rows”:[
{“articles_id”:”4″,”id”:”5621″,”type”:”articles”},
{“articles_id”:”5″,”id”:”5622″,”type”:”articles”},
]
}]
I want new data to be like this
[{“TotalRows”:2,”TopID”:1,
“Rows”:[
{“articles_id”:”4″,”id”:”5621″,”type”:”articles”,”web1″:”true”,”web2″:”true”},
{“articles_id”:”5″,”id”:”5622″,”type”:”articles”,”web1″:”true”,”web2″:”true”},
]
}]
adding object web1 and web2 (could be web1,web2,web3,web4/may change)
any idea how to add dynamically ?
the code
[code=php]$q= db_query(“select * from articles “);
while($row = mysql_fetch_assoc($q)) {
$orders[] = array(
‘articles_id’ => $row[articles_id],
‘id’ => $row[id],
‘type’ => $row[type],
);
$i++;
}
$data[] = array(
‘TotalRows’ => $i,
‘TopID’ => ‘1’,
‘Rows’ => $orders
);
echo json_encode($data);
Thank