Currently I'm trying to match types, in example Mains should be grouped together and appetizers should be grouped together, then display them in the right section. I could do this for one but I'm hoping there's another way of doing it

<?php
class Menu extends Database{

public function __construct($id, $appetisers) {
	$this->app = $appetisers;
	$this->id = $id;
	$sql = "SELECT r.id,
            m.price, i.name AS iname, i.description, i.vegan, i.itemType, i.serviceTime
            FROM restaurant r
            JOIN menu m ON m.restaurantId=r.id
            JOIN item i ON i.menuId=m.id
            WHERE r.id = :id AND i.itemType = :appetisers";
	$stmt = $this->connect()->prepare($sql);
	$stmt->bindValue(':id', $id);
	$stmt->bindValue(':appetisers', $appetisers);
    $stmt->execute();
    $this->result = $stmt->fetchAll();
}

public function name(){
	return $this->result['iname'];
}
}

    You need a top-down data-centric approach, where you retrieve all the data that you need, in the order that you want it.,

    Order the data by item name in the query (assuming you want the items under each item type alphabetically displayed), then when you fetch the data index/pivot it using the item type as the main array index. This will give you a sub-array of data for each item type that you can then reference in the appropriate order when you display the data.

      Write a Reply...