I added the images with image upload page and show the image and thumbnail images in another web page. I used the resize name with time() function. And I want this: I want each image I add to appear on the html page in order, according to the names I have just given. However, as I add the photos with the code I wrote, the order in my html page is distorted, but I always want it to continue in the order I added. How can I show the pictures I renamed with the Time() function in order on my html page?
home.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Gallery</title>
<link href='box/lightbox.min.css' rel='stylesheet' type='text/css'>
<link href='css/style.css' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Droid+Sans:400,700" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src='js/jquery-3.3.1.js' type='text/javascript'></script>
<script type="text/javascript" src="box/lightbox-plus-jquery.min.js"></script>
</head>
<body>
<div class="header">
<a class="logo">Turizm Harita Galerisi</a>
<div class="header-right">
<a href="home.php">Turizm Haritasi</a>
<a href="homeozel.php">Sehir Planlari</a>
<a href="upload.php">Image Upload Turizm Haritasi</a>
<a href="uploadozel.php">Image Upload Sehir Planlari</a>
<a href="logout.php">Log Out</a>
</div>
</div>
<div class="gallery">
<div class = "row">
<div class ="gallery-items">
<?php
$image_extensions = array("png","jpg","jpeg","gif");
$dir = 'image/';
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh)) !== false){
if($file != '' && $file != '.' && $file != '..'){
$thumbnail_path = "image/thumbnailkamu/".$file;
$image_path = "image/".$file;
$thumbnail_ext = pathinfo($thumbnail_path, PATHINFO_EXTENSION);
$image_ext = pathinfo($image_path, PATHINFO_EXTENSION);
if (array_key_exists('delete_file', $_POST)) {
$filen = $_POST['delete_file'];
if (file_exists("image/".$filen)){
unlink("image/".$filen);
unlink("image/thumbnailkamu/".$filen);
}
}
if(!is_dir($image_path) &&
in_array($thumbnail_ext,$image_extensions) &&
in_array($image_ext,$image_extensions)){
?>
<div class ="item">
<a href="<?= $image_path; ?>" data-lightbox="mygallery">
<img src="<?= $thumbnail_path; ?>">
</a>
<a class="btn btn-primary" href="<?= $image_path; ?>" download>Download</a>
<form action = "" method="post">
<input type="hidden" value="<?= $file; ?>" name="delete_file" />
<input class = "button" type="submit" value="Delete" />
</form>
</div>
<?php
}
}
}
}
closedir($dh);
}
?>
</div>
<div class = "pagination">
<div class="prev">Prev</div>
<div class="page">Page <span class="page-num"></span></div>
<div class="next">Next</div>
</div>
</div>
</div>
<script src="js/script.js" type="text/javascript"></script>
</body>
</html>
source https://stackoverflow.com/questions/67926862/how-can-i-show-the-images-in-order-in-website-with-php-and-html
No comments:
Post a Comment