I'm pretty new to php and i really struggle to work my way around it. I'm looking desperately for some help with a for loop and a include for a menu. I have a php template homepage with a menu that pulls the links via a php include link into the index.php page. I have a menu point called gallery where i have made a gallery that fetches the thumbnails and the bigger pictures via a for loop. The for loop fetches all the thumbnails the right way, but by clicking on them to activate the bigger picture, the first page of the index.php (which in my case is home.php) gets loaded in the include section instead of the bigger picture from the gallery.
I hope this makes sense, it's my first week with php, so please bare over with me
This is my include php code:
Code: Select all
<?php
$page = $_GET['file'];
if (strlen($page) == 0)
$page = "home.php";
include($page);
?>
Code: Select all
<?php
$dir = 'pic/';
$thumbs = array("small_hamburg1.jpg", "small_hamburg2.jpg", "small_hamburg3.jpg",);
$gallery = '<ul id="img_nav">' . "\n";
for($i=0; $i<count($thumbs); $i++){
$thumb = $thumbs[$i];
$find ="/small_/";
$replace ="big_";
$big = preg_replace ($find, $replace, $thumb);
$gallery .= '<li><a href="?pic='. $big .'">';
$gallery .= '<img src="' . $dir . $thumb . '" alt=" " /></a></li>';
}
$gallery .= "\n </ul> \n ";
if(isset($_GET['pic'])){
$img = $_GET['pic'];
$gallery .= '<p><img src="' . $dir . $img . '" alt="img " /></p>';
}else{
$gallery .= '<p>Pick a pic from the thumbs!</p>';
}
echo $gallery;
?>
http://www.365posts.com/school/include/ ... allery.php
I Hope you can help me.
Nils