Salve, sto facendo tramite un codice trovato su internet all'indirizzo:
http://www.9t9.in/2012/11/13/load-a-com ... h-out-sql/
le modifiche per far che posso scegliere le cartelle dove metterò le immagini quando le caricherò nelle varie directory.
ad esempio:
gallery.php?dir=wallpaper
gallery.php?dir=natura
gallery.php?dir=auto.
[code2=php]<?php
session_start();
include('inc.php');
include('template/'.$theme.'/template.php');
$title = "Galleria fotografica";
layout_header($title);
?><?php
$url = (isset($_GET["dir"])) ? trim ((string)$_GET["dir"]): '';
if(empty($url))
{
echo '404 not found';
}else{
//The directory to your images folder, with trailing slash
$dir = "public/images/".$url."/";
//Set the extensions you want to load, seperate by a comma.
$extensions = "jpeg,jpg";
//Set the number of images you want to display per page
$imagesPerPage = 1;
//Set the $page variable
if(!isset($_GET['page'])){
$page = 1;
}else{
$page = $_GET['page'];
}
//Load all images into an array
$images = glob($dir."*.{".$extensions."}", GLOB_BRACE);
//Count the number of images
$totalImages = count($images);
//Get the total pages
$totalPages = ceil($totalImages / $imagesPerPage);
//Make sure the page you are on is not greater then the total pages available.
if($page > $totalPages){
//Set the currnet page to the total pages.
$page = $totalPages;
}
//Now find where to start the loading from
$from = ($page * $imagesPerPage) - $imagesPerPage;
//Now start looping
for($i = $from; $i < ($from + $imagesPerPage); $i++){
//We need to make sure that its within the range of totalImages.
if($i < $totalImages){
//Now we can display the image!
echo "<img src='{$images[$i]}' alt='{$images[$i]}' />";
}
}
//Now to display the page numbers!
for($p = 1; $p <= $totalPages; $p++){
if($p == $page){
$tmp_pages[] = "<strong>{$p}</strong>";
}else{
$tmp_pages[] = "<a href='?dir={$url}&page={$p}'>{$p}</a>";
}
}
//Now display pages, seperated by a hyphon.
echo "<br />" . implode(" - ", $tmp_pages);
?>
<?php
}
layout_footer();
?>[/code2]
non riesco ad prendere esempio thumb_casagrande.jpg
e poi uno se clicca va a casagrande.jpg
come posso fare?
grazie mille e scusate se ritardo a rispondere ma devo andar via.
[PHP] galleria fotografica
-
- Prode Principiante
- Messaggi: 190
- Iscrizione: lunedì 14 luglio 2014, 0:50
- Desktop: KDE
- Distribuzione: Linux Kubuntu 15.04 x86_64
Re: [PHP] galleria fotografica
Non capisco bene il problema. Vuoi che uno, cliccando sull'immagine, vada all'immagine?
Nel tal caso basta un [code2=php]echo "<a href='{$images[$i]}'><img src='{$images[$i]}' alt='{$images[$i]}' /></a>";[/code2]
Nel tal caso basta un [code2=php]echo "<a href='{$images[$i]}'><img src='{$images[$i]}' alt='{$images[$i]}' /></a>";[/code2]
Usate Google prima del forum ^^
Chi c’è in linea
Visualizzano questa sezione: 0 utenti iscritti e 5 ospiti