Not sure where this question belongs so I'll try here.
I am trying to add { "tag" : "bridge"} to the end of a JSON array of objects.
I have manipulated the return query in php like this:
- $DB="bridge";
}
echo json_encode(plainQuery($DB, $query));
}
function plainQuery($db, $query) {
//echo "query 53 ".$query."\n";
$cxn = mysqli_connect(HOST,USER,PW,$db) or die("line 22 bridgeQueries.php - Couldn't connect to server");
if (mysqli_connect_errno($cxn)) {
printf("Connect failed: %s\n", mysqli_error($cxn));
exit();
};
$result = mysqli_query($cxn, $query) or exit( mysqli_error( $cxn )); // delete current data
while($row = mysqli_fetch_assoc($result)) {
$rows[]=$row;
}
$rows[]="{".'"tag"'.' : '. '"'.$db.'"'."}";
return $rows;
The last part of the returned JSON obj is like so:
,{"id":"176","playdate":"2015-02-09","player":"Rodriguez, Terri","score":"1190"},
{"id":"177","playdate":"2015-03-02","player":"Rupp, Kathy","score":"2750"},
"{\"tag\" : \"bridge\"}"]
My question is how can I get this in proper format like {"tag" : "bridge"}?
Should I try to add this last object after it is returned by AJAX in the success callback function?