Oke, here this are all the files;
image.func.php;
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
function get_images($album_id) {
$album_id = (int)$album_id;
$images = array();
$image_query = mysql_query("SELECT `image_id`, `image_name`, `album_id`, `timestamp`, `ext` FROM `images` WHERE `album_id`=$album_id");
while ($images_row = mysql_fetch_assoc($image_query)) {
$images[] = array(
'id' => $images_row['image_id'],
'name' => $images_row['image_name'],
'album' => $images_row['album_id'],
'timestamp' => $images_row['timestamp'],
'ext' => $images_row['ext']
);
}
return $images;
}
?>
I reduced this file to only the get_images function because from this file I use only the get_images function in the view_album.php file.
album.func.php;
<?php
function album_data($album_id) {
$album_id = (int)$album_id;
$args = func_get_args();
unset($args[0]);
$fields = '`'.implode('`, `', $args).'`';
$query = mysql_query("SELECT $fields FROM `albums` WHERE `album_id`=$album_id");
$query_result = mysql_fetch_assoc($query);
foreach ($args as $field) {
$args[$field] = $query_result[$field];
}
return $args;
}
function get_albums() {
$albums = array();
$albums_query = mysql_query("SELECT `albums`. `album_id`, `albums`.`timestamp`, `albums`.`name`, LEFT(`albums`.`description`, 50) as `description`, COUNT(`images`. `image_id`) as `image_count`
FROM `albums`
LEFT JOIN `images`
ON `albums`.`album_id` = `images`.`album_id`
GROUP BY `albums`.`album_id`
");
while ($albums_row = mysql_fetch_assoc($albums_query)) {
$albums[] = array(
'id' => $albums_row['album_id'],
'timestamp' => $albums_row['timestamp'],
'name' => $albums_row['name'],
'description' => $albums_row['description'],
'count' => $albums_row['image_count']
);
}
return $albums;
}
?>
I reduced this file to only the album_data function and get_images function because from this file I use only these functions in the view_album.php file. I think it makes it more easy-view for you. If you want the rest of it let me know.
view_album.php;
<?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);
}
?>
<div id="wrap">
<div id="sidebarleft">
<?php
if (isset($images)) {
foreach ($albums as $album) {
$image = true;
foreach ($images as $image) {
echo'<a href="view_album.php?album_id=', $album['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;
}
}else {echo 'Er zijn geen foto\'s in dit album';
}
?>
</div>
<div id="imagecontainer">
<div id="image">
<?php
if(isset($_GET['image_id'])){
echo'<a href="?image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '">
<img src="',htmlentities($_GET['image_id']), '" title="" /></a>';
}else if(isset($_GET['id'])){
$full_img = $images['id'];
print_r($images);
var_dump($full_img);
echo'<a href="?image_id=uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '">
<img src="',htmlentities($full_img),'" title="" /></a>';
}
?>
</div>
</div>
<div id="footer">
<?php
include 'template/footer.php';
?>
</div>
</div>
This returns no warnings, notice or errors but also no image, even no returns from print_r() or var_dump().
The $images have a value, but is this only meant for the $image?
Thanks in advance.