Example #1
0
					<th>Rating</th>
				</tr>
			<?php 
$server = "localhost";
$user = "******";
$pw = "";
$db = "cookbooknetwork";
$conn = new mysqli($server, $user, $pw, $db);
if ($conn->connect_error) {
    echo 'Connection failed: ' . $conn->connect_error;
}
$sql = "\tSELECT recipe_id, recipe_title, rating FROM recipe WHERE recipe_id IN (SELECT DISTINCT(recipe_id) FROM flag)";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    while ($row = $result->fetch_assoc()) {
        $flagCount = getFlagCount($row["recipe_id"]);
        $title = $row["recipe_title"];
        echo '<tr>
									<td><a href="flags_of_recipe.php?recipe_id=' . $row["recipe_id"] . '&flag_no=' . $flagCount . '&title=' . $title . '">' . $title . '</a></td>
									<td>' . printFlags($flagCount) . '</td>
									<td><img src="images/star' . $row["rating"] . '.png" /></td>
								</tr>';
    }
} else {
    echo '<h2>No Flags Found</h2>';
}
$conn->close();
function getFlagCount($id)
{
    $server = "localhost";
    $user = "******";
Example #2
0
    header('Location: fail.php');
}
//get pic name
$photoNamePrev = getImageNameFromDB($conn, $recipeId);
//get number of ingredients
$numberIngredients = getNumberOfIngredientsFromDB($conn, $recipeId);
//get each ingredient - format: ingredient1, ingredient2, ingredient3...
$ingredientList = getAllIngredientsFromDB($conn, $recipeId);
//get number of steps
$numberSteps = getNumberOfStepsFromDB($conn, $recipeId);
$stepList = getAllStepsFromDB($conn, $recipeId);
//get tags
$numberTags = getNumberOfTagsFromDB($conn, $recipeId);
$tagList = getAllTagsFromDB($conn, $recipeId);
//get flag count
$flagCount = getFlagCount($conn, $recipeId);
//get rating
$rating = getRecipeRating($conn, $recipeId);
$ratingCount = getRecipeRating($conn, $recipeId);
//get author
$author = getAuthorName($conn, $recipeId);
//get privacy
$privacy = getPrivacyFromDB($conn, $recipeId);
//if private
if ($privacy == 'PRIVATE') {
    //1 - check if logged in
    if ($loggedName == '') {
        header('Location: fail.php');
    }
    //2 - check if viewer is author
    if (!($loggedName == $author)) {