diff --git a/image.php b/image.php index 0625299..d5a0e26 100644 --- a/image.php +++ b/image.php @@ -14,7 +14,6 @@ include("ui/header.php"); include_once("ui/conn.php"); - // Update toast if ($_GET["update"] == "success") { echo "
Information updated
"; @@ -22,61 +21,57 @@ echo "No alt, skip
"; } - // Getting all image info from table - $get_image = "SELECT * FROM swag_table WHERE id = ".$_GET['id']; - $image_results = mysqli_query($conn, $get_image); - $image = mysqli_fetch_assoc($image_results); + // If ID present pull all image data + if (isset($_GET['id'])) { + $get_image = "SELECT * FROM swag_table WHERE id = ".$_GET['id']; + $image_results = mysqli_query($conn, $get_image); + $image = mysqli_fetch_assoc($image_results); - // Get all user details - if (isset($image['author'])) { - $get_user = "SELECT * FROM users WHERE id = ".$image['author']; - $user_results = mysqli_query($conn, $get_user); - $user = mysqli_fetch_assoc($user_results); - } + // Check if image is avalible + if (isset($image['imagename'])) { + // Display image + $image_path = "images/".$image['imagename']; + $image_alt = $image['alt']; + } else { + // ID not avalible toast + echo "Could not find image with ID: ".$_GET['id']."
"; - // Check if ID of image in URL - if (empty($_GET['id'])) { + // Replacement "no image" image and description + $image_path = "assets/no_image.png"; + $image_alt = "No image could be found, sowwy"; + } + } else { // No ID toast echo "No ID present
"; // Replacement "no image" image and description $image_path = "assets/no_image.png"; $image_alt = "No image could be found, sowwy"; - - } elseif (empty($image['imagename'])) { - // ID not avalible toast - echo "Could not find image with ID: ".$_GET['id']."
"; - - // Replacement "no image" image and description - $image_path = "assets/no_image.png"; - $image_alt = "No image could be found, sowwy"; - - } else { - // Display image - $image_path = "images/".$image['imagename']; - $image_alt = $image['alt']; - - // Add image view - if (empty($image['views'])) { - //$conn->query("UPDATE swag_table SET views=1 WHERE id=".$image['id']); - } else { - //$conn->query("UPDATE swag_table SET views=views+1 WHERE id=".$image['id']); - } } + + // Get all user details + if (isset($image['author'])) { + $get_user = "SELECT * FROM users WHERE id = ".$image['author']; + $user_results = mysqli_query($conn, $get_user); + $user = mysqli_fetch_assoc($user_results); + } else ?>".$image_alt."
"; + } else { + echo "No description provided
"; } ?>Author: ".$user['username']."
"; + } else { + echo "Author: Deleted User
"; + } } else { echo "Author: No author
"; } - // Views - //echo "Views: ".$image['views']."
"; - // Image ID echo "ID: ".$image['id']."
"; @@ -113,6 +109,7 @@ "; echo "