display images to ever user

images php coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Sun Jun 24, 2012 5:55 am

display images to ever user

Postby dimitros » Sun Jun 24, 2012 6:00 am

I am building a website using php and mysql.I have a login that is ONLY for an administrator and nothing more.Administrator can create image albums and upload images into them.Every other user does not need to login to the website. My problem is that i can't display the images to the users without being logged in to the website.Administrator can see the images when he is logged in to the website.Are there any ideas what am i doing wrong?Any kind of solution is acceptable..

Here is the code which includes the above:



$albums1 = get_albumsAll();

if (empty($albums1)){
echo '<p>There are no albums</p>';
foreach ($albums1 as $album) {
echo '<table style="display:inline-table;"><tr><td><p class="links"><a href="view_album1.php', $album, '" height="100" width="100">', $album['name'], '</a> (', $album['count'], ' images)<br />
', $album['description'], '...<br /></p> </td></tr></table>';


include 'init.php';
if (!logged_in()) {
header('Location: albums.php');

if (!isset($_GET['album_id']) || empty($_GET['album_id']) || album_check($_GET['album_id']) == false) {
header('Location: albumsAdminAll.php');

$album_id = $_GET['album_id'];
$album_data = album_data($album_id, 'name', 'description');
<div class="content3">
<div class="content_resize">
<div class="mainbar3">
<div class="article3">
<?php echo '<h2>','<span>', $album_data['name'], '</span>', '</h2>', '<p id="description">', $album_data['description'], '</p>'; ?>
<div class="clr"></div>
<div class="post_content3">

$album_id = $_GET['album_id'];
$images = get_images($album_id);

if (empty($images)) {
echo 'There are no images in this album<br /><br /><br />
<p class="links"><a href="upload_image.php">Insert images</a></p>';
} else {
foreach ($images as $image) {
echo '<table style="display:inline-table;"><tr><td><a href="uploads/', $image['album'], '/', $image['id'], '.', $image['ext'], '" height="100" width="100"><img src="uploads/thumbs/', $image['album'], '/', $image['id'], '.', $image['ext'], '" id="img" title="Uploaded ', date('D M Y / h:i ', $image['timestamp']), '" /></a>
<a href="delete_image.php?image_id=', $image['id'], '">[x]</a></td></tr></table>';
}echo '<br/><br/><p class="links"><a href="upload_image.php"><p class="links">Eισαγωγή Φωτογραφιών</p></a>
<p class="links"><a href="albumsAdminAll.php">Back to Album</a></p><br/>';





include 'func/user.func.php';
include 'func/album.func.php';
include 'func/image.func.php';
include 'func/thumb.func.php';




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`
WHERE `albums`.`user_id` = ".$_SESSION['user_id']."
GROUP BY `albums`.`album_id`
") or die(mysql_error());

//this statement checks whether the query return more than 0 rows, if yes then it will proceeds.
// you can even check if(mysql_numrows($albums_query)==1) if it should return only one row
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;

Return to “PHP coding => Images”

Who is online

Users browsing this forum: No registered users and 3 guests