I am unable to get this right! I am simply trying to create an array of names $json from mysql table data and later return this data as json using this code:
json_encode($json)
Getting syntax error in the 5th line in the following code where the $json array is assigned values from the database inside the loop.
$sql = "select * from mytable";
$result = $mysqli->query($sql);
$json = array();
while($row = $result->fetch_assoc()){
$json[] = ['id'=>$row['id'], 'text'=>$row['title']];
}
I tried replacing the single quotes with double quotes.. but no success..
having a bad day :-(