Hello,
I have the following code to select data from mysql db and save it in
a json file:
require_once "json_encode.php";
$arr = array();
$rs = mysql_query("SELECT order_id, order_no, order_no_iteration,
estimated_completion_date, other_contact_tel FROM orders")or die
("Query failed: " . mysql_error() . " Actual query: " . $rs);
while($obj = mysql_fetch_object($rs))
{
$arr[] = $obj;
}
$json = json_encode($arr);
$JSONFile = fopen("orders.json", "w");
fwrite ($JSONFile,$json);
fclose($JSONFile);
echo $json;
The "fwrite ($JSONFile,$json);" is ONLY writing 1 record to the file.
The "echo $json;" is however writing all the records to the browser.
Looks like a logic error? Can anyone have a look? I want to get onto
the next stage of reading the data from the json file into the gears
sqlite db.
Thanks, meerkat