Exemplo n.º 1
0
$categoryName = $_GET['item'];
$outputID = null;
$outputMenu = null;
$outputData = null;
$description = null;
// Load the JSON data
$data = json_decode(file_get_contents("spices.json"));
$categoryList = $data->categories;
$spices = $data->spices;
//var_dump($categories);
$outputID = checkID($categoryList, $categoryName);
//var_dump($outputID);
if ($outputID == null) {
    $description = searchDescription($spices, $categoryName);
} else {
    $outputMenu = checkMenu($categoryList, $outputID);
    //var_dump($outputMenu);
}
//
$outputData = (object) ["menu" => $outputMenu, "description" => $description];
echo json_encode($outputData);
/**
 * check output ID numbers from the category list
 * @param  [array] $categoryList
 * @param  [string] $categoryName
 * @return [array] $outputID
 */
function checkID($categoryList, $categoryName)
{
    $outputID = null;
    foreach ($categoryList as $category) {
Exemplo n.º 2
0
						<tr class="cart_menu">
							<td>Restaurant</td>
							<td>Item</td>
							<td class="price">Price</td>
							<td class="quantity">Quantity</td>
							<td class="total">Total</td>
							<td></td>
						</tr>
					</thead>
					<tbody>
						<?php 
//$username ="******";
//echo "hello";
$_SERVER["QUERY_STRING"];
$restrt_id = $_GET["Restrt_Type"];
checkMenu($restrt_id);
//$db_host    = "localhost:8889"; #change your port the mysql running port.
//$db_username= "******";# change the user name
//$db_password= "******";# change the user password
//$db_database= "ruhungry";
//$db = mysql_connect($db_host, $db_username, $db_password, $db_database);
//$sql_select = "select username, shopping_cart_info.item_id, shopping_cart_info.restrt_id, shopping_cart_info.quantity, inventory_info.price from shopping_cart_info left join inventory_info on shopping_cart_info.item_id = inventory_info.item_id where username =\"chenlongjiu\";";
/*while($row = mysqli_fetch_array($result)){
			//print html form of the shopping cart
			$outputlist = "";
			$outputlist.= '<tr>';
			$outputlist.= '<td class="cart_product">';
			$outputlist.= '<h4><a href="">'.$row["restrt_id"].'</a></h4>'
			$outputlist.= '</td>';
			$outputlist.= '<td class="cart_description">';
			$outputlist.= '<p>'.$row["item_id"].'</p>';