deleting crumbles

master
snowflake 3 years ago
parent 7d819c580d
commit 685c052428

@ -18,10 +18,14 @@ $brewery_id = $record["brewery_id"];
$brewery = getRecord($pdo, "brewery", $brewery_id )["name"]; $brewery = getRecord($pdo, "brewery", $brewery_id )["name"];
require("view/mainContent/mainContent.php"); require("view/mainContent/mainContent.php");
require("view/mainContent/beerExtraInfo.php"); require("view/mainContent/beerExtraInfo.php");
echo " <div class=\"content\">
<div class=\"box\">
<article>";
if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){ if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
if(isThisBound($pdo, "list", $_GET["id"], $_SESSION["id"])){ if(isThisBound($pdo, "list", $_GET["id"], $_SESSION["id"])){
$rating = getRating( $pdo, $_GET["id"], $_SESSION["id"])["rating"]; $rating = getRating( $pdo, $_GET["id"], $_SESSION["id"])["rating"];
showStars($_GET["id"], $rating); showStars($_GET["id"], $rating);
unfollowButton("list", $_GET["id"]); unfollowButton("list", $_GET["id"]);
} else { } else {
@ -29,6 +33,9 @@ if(isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true){
} }
} }
echo " </article>
</div>
</div>";
$array = listTagsByBeer($pdo, $_GET["id"]); $array = listTagsByBeer($pdo, $_GET["id"]);

@ -83,7 +83,7 @@ function listTagsByBeer($pdo, $beer){
return $arrayBeersXTags; return $arrayBeersXTags;
} }
function listBeersByTag($pdo, $tag){ function listBeersByTagID($pdo, $tag){
$conn = $pdo; $conn = $pdo;
try { try {
@ -112,7 +112,7 @@ function listBeersByUser($pdo, $user){
return $arrayOfBeers; return $arrayOfBeers;
} }
function listBeersByBreweryNAN( $pdo ){ function listBreweriesNAN( $pdo ){
$conn = $pdo; $conn = $pdo;
try { try {
$sql = "SELECT * FROM brewery"; $sql = "SELECT * FROM brewery";
@ -124,4 +124,79 @@ function listBeersByBreweryNAN( $pdo ){
echo "Error in Breweries: " . $e->getMessage(); echo "Error in Breweries: " . $e->getMessage();
} }
return $arrayOfBreweries; return $arrayOfBreweries;
} }
function listBeersNAN( $pdo ){
$conn = $pdo;
try {
$sql = "SELECT * FROM beer";
$stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayOfBreweries = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Breweries: " . $e->getMessage();
}
return $arrayOfBreweries;
}
function listBeersByTag($pdo, $tag){
$conn = $pdo;
try {
$stmt = $conn->prepare("SELECT * FROM beer_has_tag JOIN tag ON tag_id WHERE tag_title LIKE $tag");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayTagsXBeers = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Beers: " . $e->getMessage();
}
print_r($arrayTagsXBeers);
return $arrayTagsXBeers;
}
function listBeersByName($pdo, $name){
$conn = $pdo;
try {
$stmt = $conn->prepare("SELECT * FROM beer WHERE name LIKE $name");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayTagsXBeers = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Beers: " . $e->getMessage();
}
print_r($arrayTagsXBeers);
return $arrayTagsXBeers;
}
function listBreweryByName($pdo, $name){
$conn = $pdo;
try {
$stmt = $conn->prepare("SELECT * FROM brewery WHERE name LIKE $name");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayTagsXBeers = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Beers: " . $e->getMessage();
}
print_r($arrayTagsXBeers);
return $arrayTagsXBeers;
}
function listArticleByName($pdo, $title){
$conn = $pdo;
try {
$stmt = $conn->prepare("SELECT * FROM article WHERE title LIKE $title");
$stmt->execute();
$result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
$arrayTagsXBeers = $stmt->fetchAll();
} catch (PDOException $e) {
echo "Error in Beers: " . $e->getMessage();
}
print_r($arrayTagsXBeers);
return $arrayTagsXBeers;
}

@ -1,5 +1,94 @@
<?php <?php
session_start(); session_start();
require("model/db.php");
require("controller/listLatest.php");
require("view/mainContent/userButtons.php");
print_r($_GET); print_r($_GET);
header("location: index.php");
require("view/header.php");
require("view/sidebar.php");
echo "<div class=\"content\">";
if($_GET["type"]=="tag"){
$array=listBeersByTag($pdo, $tag);
}
if($_GET["type"]=="beer"){
$name=$_GET["keyword"];
$array=listBeersByName($pdo, $name);
foreach($arrayOfBeers as $row):
echo "
<div class=\"box\">
<article>
<a href=\"beer.php?id=";
echo $row["id"];
echo "\"><h2>";
echo $row["name"];
echo " ";
echo $row["degree"];
echo "˚</h2></a>";
echo "</br>";
echo "</article>
</div>";
endforeach;
}
if($_GET["type"]=="brewery"){
$name=$_GET["keyword"];
$array=listBreweryByName($pdo, $name);
}
if($_GET["type"]=="article"){
$name=$_GET["keyword"];
$array=listArticleByName($pdo, $name);
foreach($array as $row) :
echo "<div class=\"box\">";
echo "<article>";
echo "<a href=\"article.php?id=";
echo $row["id"];
echo "?>\" ><h2>";
echo $row['title'];
echo "?></h2></a>";
echo "Published on:<time pubdate=\"pubdate\">";
echo $row['time'];
echo "</time>";
echo "<p><em>";
echo substr($row['body'],0 ,120);
echo "...</em></p> ";
echo "<a/rticle>";
echo "</div>";
endforeach;
}
if($_GET["type"]=="all"){
$name=$_GET["keyword"];
$array=listArticleByName($pdo, $name);
foreach($arrayOfBeers as $row):
foreach($array as $row) :
echo "<div class=\"box\">";
echo "<article>";
echo "<a href=\"article.php?id=";
echo $row["id"];
echo "?>\" ><h2>";
echo $row['title'];
echo "?></h2></a>";
echo "Published on:<time pubdate=\"pubdate\">";
echo $row['time'];
echo "</time>";
echo "<p><em>";
echo substr($row['body'],0 ,120);
echo "...</em></p> ";
echo "<a/rticle>";
echo "</div>";
endforeach;
$array=listBreweryByName($pdo, $name);
$array=listBeersByName($pdo, $name);
$array=listBeersByTag($pdo, $tag);
}
echo "</div>";
include("view/footer.php");
//header("location: index.php");

@ -7,10 +7,10 @@ require_once("controller/listLatest.php");
<?php <?php
$title = "LATEST Beers"; $title = "Beers";
$where = "5"; $where = "5";
$what = "beer"; $what = "beer";
$array = listLatestBeers($pdo, $where); $array = listBeersNAN($pdo);
require("sidebar/sidebarLister.php") require("sidebar/sidebarLister.php")
@ -18,11 +18,11 @@ require("sidebar/sidebarLister.php")
<?php <?php
$title = "LATEST Breweries"; $title = "Breweries";
$where = "5"; $where = "5";
$what = "brewery"; $what = "brewery";
$array = listBeersByBreweryNAN($pdo); $array = listBreweriesNAN($pdo);
require("sidebar/sidebarLister.php"); require("sidebar/sidebarLister.php");

Loading…
Cancel
Save