php-gallery/index.php

56 lines
1.9 KiB
PHP
Raw Normal View History

2022-07-20 23:06:21 +00:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>UwU</title>
2022-07-21 14:53:04 +00:00
<link rel="stylesheet" href="css/master.css">
2022-07-20 23:06:21 +00:00
<link href="https://fonts.googleapis.com/css2?family=Rubik" rel="stylesheet">
2022-07-22 00:21:48 +00:00
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@600&amp;display=swap">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@500&amp;display=swap">
2022-07-20 23:06:21 +00:00
</head>
<body>
2022-07-21 14:53:04 +00:00
<?php include('ui/header.php'); ?>
2022-07-20 23:06:21 +00:00
2022-07-21 18:42:03 +00:00
<?php
if ($_GET["del"] == "true") {
2022-07-22 00:21:48 +00:00
echo "<p class='alert alert-high space-bottom'>Successfully deleted image: ".$_GET['id']."</p>";
2022-07-21 18:42:03 +00:00
}
?>
<div class="info-text center">
<h1>Fluffys Super Duper Secrete Project!</h1>
<p>Fluffy's test website on uploading images to a database!</p>
</div>
2022-07-20 23:06:21 +00:00
<?php
// Attempt database connection
$conn = mysqli_connect("localhost", "uwu", "password", "swag");
// If connecton failed, notify user
if (!$conn) {
2022-07-21 18:42:03 +00:00
echo "<p class='alert alert-high'>Could not connect to database</p>";
2022-07-20 23:06:21 +00:00
}
2022-07-21 14:53:04 +00:00
// My terrible workaround for not being able to show deletion status up here
if (isset($_GET['d'])) {
echo "<p class='alert default'>Image ".$_GET['d']." has been modified, <a href='#deleted'>view status here</a></p>";
2022-07-20 23:06:21 +00:00
}
?>
2022-07-21 14:53:04 +00:00
<div class="gallery-root flex-left">
2022-07-20 23:06:21 +00:00
<?php
// Reading images from table
$img = mysqli_query($conn, "SELECT * FROM swag_table");
while ($row = mysqli_fetch_array($img)) {
2022-07-21 14:53:04 +00:00
echo "<div class='gallery-item'>";
2022-07-20 23:06:21 +00:00
// Image loading
2022-07-21 14:53:04 +00:00
echo "<a href='https://superdupersecteteuploadtest.fluffybean.gay/image.php?id=".$row['id']."'><img class='gallery-image' loading='lazy' src='images/".$row['imagename']."' id='".$row['id']."'></a>";
2022-07-20 23:06:21 +00:00
echo "</div>";
}
?>
</div>
2022-07-21 14:53:04 +00:00
<?php include('ui/footer.php'); ?>
2022-07-20 23:06:21 +00:00
</body>
</html>