Re: photo gallery
Posted: Tue Jan 22, 2013 9:43 pm
I am still trying to get the main image on the same page as the thumbnails and still I am not succeeding. I am still trying because I think it must be possible.
I have a few questions.
The code is now;
After $image = false; I try to change the $image variable in an integer. I hoped that I could use the $image variable again but it is not working.
I hope you can help me out here, thanks.
http://www.robcnossen.nl/view_album.php?album_id=7
I have a few questions.
After the $image = false; I can't use the variable $image anymore, it then maybe should be based on $_GET['image_id']. Can you give my an example of how I could do that because I don't know what you mean. Or I could keep the value of the loop but then with a different variable name. I tried for example $image = $img to get a different variable name with the value from the loop but maybe it is not a good way to change a variable name?Where you use $image on line 38 above it will not have an array value since you define it as false near the top. I'm not really sure what should be in it's place :/ maybe it should be based on $_GET['image_id'] ? You could keep the value form the loop too, you would just need to use a different variable name.
The code is now;
<?php include 'core/init.php'; if (isset($_GET['album_id'])) { $album_id = $_GET['album_id']; $album_data = album_data($album_id, 'name', 'description'); echo '<h3>', $album_data['name'], '</h3><p>', $album_data['description'], '</p>'; $albums = get_albums(); $images = get_images($album_id); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <div id="wrap"> <div id="sidebarleft"> <?php if (empty($images)) { echo 'Er zijn geen foto\'s in dit album'; } else { foreach ($albums as $album) { $image = true; foreach ($images as $image) { echo'<a href="view_album.php?album_id=', $album['alb_id'],'&image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '"><img src="uploads/thumbs/', $image['album'], '/', $image['id'], '.', $image['ext'], '" title="" /></a><a href="delete_image.php?image_id=', $image['id'],'">x</a> '; $image = false; } if(!$image) break; } } ?> </div> <div id="imagecontainer"> <div id="image"> <?php $image = (int)$image; $full_image=(isset($_GET['image_id'])) ? $_GET['image_id'] : (int)$images[0]; var_dump($images); echo'<a href="?image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '"><img src="',htmlentities($full_image), '" title="" />'; ?>
After $image = false; I try to change the $image variable in an integer. I hoped that I could use the $image variable again but it is not working.
I hope you can help me out here, thanks.
http://www.robcnossen.nl/view_album.php?album_id=7