$supplierData = array(); $query2 = $db->suppliers(); foreach ($query2 as $p) { $supplierData[] = findSupplierDetails($query2); } $data = array_merge($supplierData, $productData); $app->response()->header('content-type', 'application/json'); echo json_encode(array('supplier_details' => $supplierData, 'supplier_products' => $productData)); } }); // For finding usages of given type say tiles or marbles $app->get('/shiningfloor/products(/:type)/usages', function ($type) use($app, $db) { $usages_area; $type_id = $db->types()->where('type_name', $type)->select('id')->fetch(); // $query = $db->products->where('type_id',$type_id); $query = $db->products_usages()->where('type_id', $type_id); foreach ($query as $p) { $usages_area[] = $p->usages['usage_name']; } $app->response()->header('content-type', 'application/json'); echo json_encode(array('products_name' => $type, 'locations' => $usages_area)); // echo json_encode($_GET['sortkey']); }); // -------------------------------------- $app->get('/shiningfloor/chooseproducts(/:id)', function ($id = null) use($app, $db) { $data = array(); //$query = $db->products(); global $colorFilters, $priceFilters, $brandFilters; global $resultPerPage, $pageNo; if (isset($_GET['pageNo'])) { $pageNo = (int) $_GET['pageNo'];