I'm trying to convert the result array from Mysql to JSON format, the format doesn't seems to be correct, a comma is missing between each object. Please advice, thank you.
I'm aware that im using the deprecated version of php here.
$result = mysql_query("SELECT * FROM patientvaccinedetail")or
die(mysql_error());
while($row = mysql_fetch_array( $result,MYSQL_ASSOC)) {
$specific = ["message" => $row["message"],
"mobile" => $row["mobile"]];
print_r (json_encode($specific));
}
Current Result:
{"message":"hello","mobile":"12345678"}{"message":"hi","mobile":"87878965"}
Desired Result:
{"message":"hello","mobile":"12345678"}, {"message":"hi","mobile":"87878965"}