Jump to content

Recommended Posts

I'm trying to wright my own gallery... And I figgerd I wont a row of images in the bottem when you click one it comes up in a bigger version in the mittle on the screan... I'm geussing that can be done by a <a href="zz" target="xx"></a>, but can it realy be done and how do I get it to make that link apear on every img from the database without having to add it to every img... So I geus what i'm asking is....

Can I make a link on images that change on demand to another img from the database and link to the NEW img...

Link to comment
https://forums.phpfreaks.com/topic/116944-gallery/
Share on other sites

yes. quite easily actually.

 

You'll grab the image location or whatever from the database, put it into a associative array, and then echo the database info(through the array) into HTML tags. for example: <img src="<?php echo $row['imagelocation']; ?>"></img>

 

Regards ACE

Link to comment
https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601385
Share on other sites

If you wanted a script that immediately updates (eg you click the picture and instantly it appears bigger), then you might want to look at javascript for this.

 

 

I wont a row of 4-5 images in the bottom of the screan and when you click one it will be linked to the center on the screan in a big version... But the bottom ones allsow have to be able to be replaced by a "Next" and "prevois" botten so that ther will apear 4-5 new img's that still works as links...

Link to comment
https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601416
Share on other sites

<?php

$num_imgs = sizeof($image_rows) - 1;
$current_row = (int) $_GET['image'];
$has_previous = false;
$has_next = false;

if ($current_row >= $num_imgs) {
    $current_row = $num_imgs;
} else {
    $has_next = true;
}

if ($current_row <= 1) {
    $current_row = 1;
} else {
    $has_previous = true;
}

// the image
echo '<img src="' . $image_rows[$current_row]['image_path'] . '" />';

// previous
echo ($has_previous ? '<a href="?image=' . $current_row . '">previous</a>' : '<b>previous</b>');

// next
echo ($has_next ? '<a href="?image=' . ($current_row + 1) . '">next</a>' : '<b>next</b>');

Link to comment
https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601489
Share on other sites

It's quite simple to use an iframe to house your big image. Within the cell you want the image placed, put this:

 

<iframe 
src ="/blank.html"
width="100%" name="updatebox" scrolling="auto" frameborder="0">
</iframe>

 

You can set the height and width, scrolling frameborder etc as you require.

 

As for the image gallery:

 

$listID = 0;
$resultsID = mysql_query("SELECT imageID, thumb, location FROM images", $linkID) 
or die(mysql_error());
while (list($imageID, $thumb, $location) = mysql_fetch_row($resultsID))
	{
		$imagearray["$listID"] = array('thumb'=>"$thumb",
			'location'=>"$location",
			'imageID'=>"$imageID");
		$listID += 1; 
	} 

 

Once the array is set up you can retrieve the images with this code:

 

<a href="<?php print $imagearray["$number"]['location']; ?>" target="updatebox"><img scr="<?php print $imagearray["$number"]['thumb']; ?>"></a>

 

Where you alter the $number by one each time you repeat it; perhaps with a while ($number < $totalimages) { show image, then increase $number by 1, ladeda sorta deal; But keep in mind you're starting from 0 (not 1).

 

Hope this helps. Let me know if you wanted to include additional pages. It's fairly simple.. but if you care to try yourself, just multiply your desired image display limit (eg 5) by the page number, and start your $number from there.

 

Link to comment
https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601574
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Sorry for not clarifying that. Sometimes it's hard to know what to include and what not to.

 

Sorry for the late response as well.. I've been away on holiday, so I hope you haven't been in a hurry to get this done.

 

My database is set up quite simply. Rather than have a script that resizes your images on the fly, I have a thumbnail image and a proper image. My use of these in my code (in hindsight) would have been quite confusing. The $thumb and $location is where the images are located. The $thumb is the filename of the thumnail, and the $location is the filename of the full-sized image: 'thumb0034.jpg' and 'image0034.jpg'. These are examples only.. if you wanted some additional security, you'd be best off generating random names for you filenames, otherwise people could determine the location of you full-sized image by knowing the thumbnail suffix (the number). If you wanted a script that generates random names, let me know and I'll post it.

 

The $imageID is the Key. When you want to display the images, you use this:

 

print "<img src=\"pics/thumb/".$file."\" width=321 height=241 alt=\"Thumbnail Image\">";

 

Or use the link script I posted below. As an alternative, you can create a form that will Post rather than Get information between pages; use your thumbnail as a button for a form. To the end-user, they wont know the difference, but it gives you some benefits in how you handle links. This helps with keeping your file names secret, keeps addresses small, and also allows you to pass over a much larger amount of information discretely, which means you have greater flexibility in site maneuverability... but it's a little harder to do.

 

Link to comment
https://forums.phpfreaks.com/topic/116944-gallery/#findComment-620712
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.