Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start(); //start new or resume existing session
- //set session variable "view" to an empty string -- this is for the viewImage.php page
- echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //echo opening xml statement
- ?>
- <!DOCTYPE html> <!-- set DOCTYPE to html -->
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!--set xml version-->
- <head> <!--open head tag-->
- <meta charset="utf-8" /> <!-- set charset -->
- <title>Image Resizer - Home</title> <!-- title of page -->
- <script src="http://code.jquery.com/jquery-latest.js"></script>
- </head> <!--close head tag -->
- <body> <!-- open body tag-->
- <?php
- include("includes/header.php"); //include the header.php page contents
- include("includes/OpenDBConn.php");
- if(empty($_SESSION["view"])) {
- $_SESSION["view"] = "All";
- }
- if($_SESSION["loggedin"] == "true" && $_SESSION["role"] != "User" && $_SESSION["role"] != "Super Admin") {
- ?>
- <center><b><h1 style ="color:red;"> Welcome, <?php echo $_SESSION["role"] . " Cuisine Admin " . $_SESSION["firstname"] . " " . $_SESSION["lastname"]; ?>! </h1></b></center>
- <?php } ?>
- <?php
- if($_SESSION["loggedin"] == "true" && ($_SESSION["role"] == "User" || $_SESSION["role"] == "Super Admin")) {
- ?>
- <center><b><h1 style ="color:red;"> Welcome, <?php echo $_SESSION["role"] . " " . $_SESSION["firstname"] . " " . $_SESSION["lastname"]; ?>! </h1></b></center>
- <?php } ?>
- <center><b><h4 style="color:green;"> Welcome to <i>Culinary Clicks</i>, your one-stop shop for anything food image related!</h4></b>
- <?php if($_SESSION["loggedin"] != "true" && $_SESSION["errormessage2"] != "") { ?>
- <div class="alert alert-warning" role="alert">
- We are sorry, but we are unable to register your account at this time due to the following error - <br>
- <?php echo $_SESSION["errormessage2"]; ?> <br>
- Please try again.
- </div>
- <?php }
- if($_SESSION["loggedin"] != "true" && $_SESSION["errormessage"] != "") {
- ?>
- <div class="alert alert-warning" role="alert">
- We are sorry, but we are unable to log you in to your account at this time due to the following error - <br>
- <?php echo $_SESSION["errormessage"]; ?> <br>
- Please try again, or create a new account if you don't already have one.
- </div>
- <?php }
- if($_SESSION["loggedin"] != "true" && $_SESSION["status"] != "") {
- ?>
- <div class="alert alert-success" role="alert">
- <?php echo $_SESSION["status"]; ?>
- </div>
- <?php } ?>
- </center>
- <center><b> Please select a cuisine to view all sorts of foods that it has to offer.</b></center>
- <center>
- <form id = "form0" action = "doViewImage.php" method = "POST"><!--form with action being doViewImage.php and method being POST-->
- <select class="form-control form-control-lg" name = "imgs" id = "imgs"><!--dropdown menu in form to select image to view in original size and resized size-->
- <option value = "All">All</option>
- <?php
- $sql = "SELECT cuisine FROM Categories"; //sql statement to select all the imageID elements from table Images
- $result = $conn->query($sql); //process sql statement for my database;
- if($result->num_rows > 0) { //if there are more than 0 rows of elements in the result variable
- $num_results = $result->num_rows; //set $num_results to num_rows
- }
- else {
- $num_results = 0; //otherwise set $num_results to 0
- }
- while ($row = $result->fetch_assoc()) { //while there are still rows of imageID elements left in the associative array $result
- ?>
- <option value = <?php echo $row["cuisine"]; ?> <?php if($_SESSION["view"] == $row["cuisine"]) { echo "Selected";} ?>><?php echo $row["cuisine"]; ?></option> <!-- create a form dropdown menu element with the text being the imageID in the current row in $result-->
- <?php } ?> <!-- close while loop -->
- </select> <!--close select tag -- end of dropdown menu -->
- <br> <!--new line-->
- <center><button type="submit" class="btn btn-primary">View Image</button></center><br><br><!--button to submit form to doViewImage.php-->
- </form></center> <!--close form tag -- end of form -->
- <center>
- <!-- READ FROM HERE -->
- <?php
- if($_SESSION["view"] != "All") {
- $sql2 = "SELECT primarykey, imageID, imgDesc, imageNum FROM Images WHERE typeID = '". $_SESSION["view"] . "'";
- } else {
- $sql2 = "SELECT primarykey, imageID, imgDesc, imageNum FROM Images";
- }
- $result2 = $conn->query($sql2);
- if($result2->num_rows > 0) { //if there are more than 0 rows of elements in the result variable
- $num_results2 = $result2->num_rows; //set $num_results to num_rows
- }
- else {
- $num_results2 = 0; //otherwise set $num_results to 0
- }
- ?>
- <?php if($num_results2 == 0) { ?>
- <h4 style ="color:#f14d00"> No images avialable for this category.</h4>
- <?php } ?>
- <div id = "easyPaginate" class = "image-row">
- <?php while ($row2 = $result2->fetch_assoc()) { //while there are still rows of imageID elements left in the associative array $result
- ?>
- <a href= "<?php echo "upload/" . $row2["imageID"]; ?>" data-lightbox="<?php echo "img - " . $row2["primarykey"]; ?>" data-title="<?php echo $row2["imgDesc"]; ?>">
- <img src = <?php echo "thumb/" . $row2["imageID"]; ?>>
- </a>
- <a href= "<?php echo "upload/" . $row2["imageID"]; ?>" class="btn btn-info" role="button" download>Download Image</a>
- <br><br>
- <?php } ?>
- </div>
- </center>
- <script src="lightbox.js"></script>
- <script src="jquery.easyPaginate.js"></script>
- <script src="jquery.easyPaginate.js"></script>
- <script>
- $('#easyPaginate').easyPaginate({
- paginateElement: 'img',
- elementsPerPage: 8,
- effect: 'climb'
- });
- </script>
- </body>
- <!-- <script src="lightbox.js"></script> -->
- <!--<script src="jquery.easyPaginate.js"></script>
- <script>
- $('#easyPaginate').easyPaginate({
- paginateElement: 'img',
- elementsPerPage: 8,
- effect: 'climb'
- });
- </script> -->
- </html>
- <?php include("includes/CloseDBConn.php"); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement