Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as PHP by uiokkkkk ( 6 years ago )
<?php
//connecting to database
require "database.php";
error_reporting(E_ALL);
?>
<html>
<head>
//bootstrap script links
</head>
<body>
<?php
$getRestaurantData = $conn->prepare("SELECT res_id FROM basicinfo");
try
{
$getRestaurantData->execute();
}
catch(PDOException $err)
{
echo $err;
}
echo '<input class="form-control" id="searchAnything" type="text" placeholder="Search..">';
while ($result = $getRestaurantData->fetch(PDO::FETCH_ASSOC))
{
//restaurant id
echo "<div class='container align-items-center ' id='myDIV'>";
//getting basicinfo data by res_id
echo "<div class='row'>";
echo "<div class='col-sm'>";
getRestaurantBasicInfo($result['res_id']);
echo "</div>";
//getting highlights data by res_id
echo "<div class='col-sm'>";
echo "<nav>";
echo " <div class='nav nav-tabs' id='nav-tab' role='tablist'>";
echo "<a class='nav-link active' id='nav-highlights-tab' data-toggle='tab' href='#nav-highlights' role='tab' aria-controls='nav-highlights' aria-selected='true'>Highlights</a>";
echo "<a class='nav-link' id='nav-review-tab' data-toggle='tab' href='#nav-reviews' role='tab' aria-controls='nav-reviews' aria-selected='false'>Reviews</a>";
echo "</div>";
echo "</nav>";
echo "<div class='tab-content' id='nav-tabContent'>";
echo "<div class='tab-pane fade show active' id='nav-highlights' role='tabpanel' aria-labelledby='nav-highlights-tab'>" . getRestaurantHighlights($result['res_id']) .
"</div>";
echo "<div class='tab-pane fade' id='nav-reviews' role='tabpanel' aria-labelledby='nav-reviews-tab'>" . getRestaurantReviews($result['res_id']) . "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</div>";
}
echo "<script>
console.log('yoo');
$(document).ready(function () {
$('#searchAnything').on('keyup', function () {
var value = $(this).val().toLowerCase();
$('#myDIV *').filter(function () {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>";
//get restaurant_info data
function getRestaurantBasicInfo($restaurant_id)
{
require "database.php";
$sql = "select res_id, name, address, locality, city, city_id, cuisines, timings, average_cost_for_two, price_range,
currency, aggregrate_rating, rating_text, photo_url, menu_url, phone_number, establishment, url
from basicinfo where res_id = $restaurant_id ";
try
{
$stmt = $conn->prepare($sql);
$stmt->execute();
$resdata = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($resdata as $res_data)
{
echo "<a href='{$res_data["url"]}'><h2 class='text-center'>{$res_data["name"]}</h2></a>";
echo "<h2 class='text-center' style='color:purple;'> <span style='color:orange;'>{$res_data["establishment"]}</span/></h2>";
echo "<h4>{$res_data["aggregrate_rating"]} <span class='fa fa-star checked'></span></h4>";
echo "<p class='text-right'><a href='{$res_data["photo_url"]}'>Photos</a></p>";
echo "<p class='text-right'><a href='{$res_data["menu_url"]}'>Menu</a></p>";
echo "<h4 class='text-center'>{$res_data["cuisines"]}</h4>";
echo "<p class='text-center'><span style='color:purple;' > $ {$res_data["average_cost_for_two"]} for {$res_data["price_range"]} people(approx.)</span></p>";
echo "<br>";
echo "<p class='text-center'>{$res_data["address"]}</p>";
$res = str_replace(',', '<br />', $res_data["timings"]);
echo " <p class='text-center'> <b>Timings:</b> {$res}</p>";
echo "<br>";
echo "<p class='text-center'>Phone number: {$res_data["phone_number"]}<p>";
}
}
catch(PDOException $e)
{
echo '{error":{"text":' . $e->getMessage() . '}}';
}
}
//get restaurant_highlights data
function getRestaurantHighlights($restaurant_id)
{
require "database.php";
$sql = "select res_id, highlights
from highlights where res_id = $restaurant_id ";
try
{
$stmt = $conn->prepare($sql);
$stmt->execute();
$resdata = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($resdata as $res_data)
{
echo "<ul>";
echo "<li>{$res_data["highlights"]}</li>";
echo "</ul>";
}
}
catch(PDOException $e)
{
echo '{error":{"text":' . $e->getMessage() . '}}';
}
}
//get restaurant_reviews data
function getRestaurantReviews($restaurant_id)
{
require "database.php";
$sql = "select res_id, review from reviews where res_id = $restaurant_id ";
try
{
$stmt = $conn->prepare($sql);
$stmt->execute();
$resdata = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($resdata as $res_data)
{
echo "<td>{$res_data["review"]}</td>";
echo "<hr>";
}
}
catch(PDOException $e)
{
echo '{error":{"text":' . $e->getMessage() . '}}';
}
}
?>
</body>
</html>
Revise this Paste