function get_data()
{
$connect = mysqli_connect("localhost", "root", "root", "Database");
$query = "SELECT * FROM Furniture";
$result = mysqli_query($connect, $query);
$categories = array();
$row = mysqli_fetch_array($result);
{
$categories[] = array(
'mapwidth' => "2000",
'mapheight' => "2000",
);
}
This is what I have so far, but how would I be able to create an array of "categories" so that the json file looks like this,
{
"mapwidth": "2000",
"mapheight": "2000",
"categories": [
{
"id": "furniture",
"title": "furniture",
"color": "#4cd3b8",
"show": "false"
},
{
"id": "rooms",
"title": "Rooms",
"color": "#63aa9c",
"show": "true"
}
],
I tried to do this but I was only able to get one row to display but am not sure how to iterate through the database so that every row will display the "id", "title", "color", and "show" within the brackets as seen in the json file. So I pretty much just want the json file to look exactly like the one shown here.