Jump to content

Images jumbled until page-refresh


tommybfisher

Recommended Posts

I've created a photo gallery with php. The gallery is functioning fine, apart from when an image is uploaded the page displays a couple of the images stacked over one-another. The page is displayed in the correct layout when the page is refreshed. This is happening after each photo upload. I wondered if anyone has come across this problem or if its obvious if there's something in my script that's causing this?

 

<?php
echo "<div class='gallery_row_divide'>";
include "processes/connection.php";
$table = "gallery";
$i = 0;	

$data = mysql_query("SELECT id, name, filetype FROM $table ORDER BY id DESC") or die(mysql_error);

while ($datarow = mysql_fetch_array($data))
{
	$name = $datarow['name'];
	$id = $datarow['id'];
	//determine photo & thumbnail name and location
	if($datarow['filetype'] == "image/png")
		$type = "png";
	else
		$type = "jpg";
	$photo_name = "000". $id;
	$photo_name = substr($photo_name, -4);
	$photo_name = $photo_name. "." .$type;
	$thumbname = "tb_" .$photo_name;
	$thumbname_address = "uploads/thumbs/" .$thumbname;
	$photo_address = "uploads/" .$photo_name;

	//display image
	echo "<div class='gallery_photo_divide'><div class='gallery_photo_valouter'><div class='gallery_photo_valmid'><div class='gallery_photo_valinner'><a href='$photo_address' class='lightbox'><img src='$thumbname_address' alt='photo by $name' class='shadow pic' /></a><br />";
	if(!empty($name))
		echo "<div class='gallery_text_divide'>Photo taken by " .$name. "</div><!--end of .gallery_text_divide-->";
	else
		echo "<div class='gallery_text_divide'> </div><!--end of .gallery_text_divide-->";
	echo "</div><!--end .gallery_photo_valinner--></div><!--end .gallery_photo_valmid--></div><!--end .gallery_photo_valouter--></div><!--end of .gallery_photo_divide-->";
	++$i;
	if($i % 3 == 0)
		echo "</div><!--end of .gallery_row_divide--><div class='gallery_row_divide'>";
}
if(!($i % 3 == 0))
	echo "</div><!--end of .gallery_row_divide-->";
mysql_close($con);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.