Jump to content

Recommended Posts

Hey, Thanks for looking.

 

Im having a bit of a problem. Im making a website for a photographer and I showed him a design and a way for him show off his work.

 

The design can be seen here:

www.ls12style.co.uk/projects/Wonstar/gallery.php?func=viewal&alid=1

 

The problem i'm having is that when it comes to displaying the 5 thumbnails at the bottom, i don't know what to do. I mean i can everything from a database no problem but i think what i need is a bit of pagination.

 

what i want to happen is the image in the middle be the current image that is on display and the two images to the left and to the right is that these are the next/previous two images. as you can see from the link, the id of the image to be displayed is taken from the URL. i also want a next and previous button that shows the next image in the 'film strip'.

 

any ideas how i can do this?

 

Thanks in advanced

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

flash would be a better way to make this site...

 

 

however you can do this..

 

you might look into ajax for this...

 

other wise maybe use alil javascript and simply switch out the images based on which images are there and where the user clicks

 

If using js which is not really recommended. if you can help it...

 

make a big fuction that has the file names it and run a check on which file name is up in the middle then based on that replace the other img src's with the following image in line..

 

if you do this through php you'll be forced to refresh the page each time..

Link to comment
https://forums.phpfreaks.com/topic/113594-pagination/#findComment-583703
Share on other sites

"Pagination" is mostly correct.

How to do it, in your case, depends on how the site is designed around that.

 

If you don't have anything in place yet, I suggest taking a look around for some pre-built image gallery solutions.

 

I'm sorry that I don't have a definitive answer for you, but the least I can do is tell you to look up some tutorials on pagination.

 

Basically, you'll need to be able to find out what the previous and next images are in the list/sequence, relative to the current image... which you already said was defined in the URL. This will probably be in the form of a sequential ID from a database, or some such.

 

So it depends on where/how you're retreiving the images.

Link to comment
https://forums.phpfreaks.com/topic/113594-pagination/#findComment-583721
Share on other sites

well, i have already sort of started work on the gallery. and plus i like the experience.

 

like you guessed the image id in the url is based on the id of the image stored in a DB.

the ID the an auto inc. int. but the thing is there might be 50 images belonging to 5 different albums and not all of the 10 images will be next to each other. so the id's of the images belonging to album 3 could go 23,24,25,27,30,37,42,43,50

 

i guess i would do something like this:

<?php 
$albId = $_GET['albid'];
$imgId = $_GET['picid'];

//query
$query = "SELECT * FROM table WHERE table_albumid='".$albId."'"; // selects all images belonging to the album
$result = mysql_query($query); //queries the db

while ($row = mysql_fetch_array($result)) { //start a loop?
//and then this is where i get stumped.
//i imagine i would use an if statement to see if the current image id matches $imgId
//then work out which ones are next
//but how do i work out the previous?

}
?>

 

Link to comment
https://forums.phpfreaks.com/topic/113594-pagination/#findComment-583802
Share on other sites

So your "$query = "SELECT * FROM table WHERE table_albumid='".$albId."'";" query returns the ID's in the order you want?

 

You could use the limit function (how I handle pagination). 

 

$query = "SELECT * FROM table WHERE table_albumid='$albID' order by `Index` LIMIT $start, 5;

 

Will pull the first 5 records ordered by index starting at image $start.  To recenter the film strip, all you need to do is figure out the starting record.  Say you need to center on the 10th image.  That means the first image of the set will be image 8 (if using 5 images).  So all you do is set $start = 8 and it fetches 5 records starting at record 8.  It doesn't matter what the image Id's are since you are not ordering by that.

Link to comment
https://forums.phpfreaks.com/topic/113594-pagination/#findComment-583830
Share on other sites

i was just throwing 'Index' out there because I didn't know your db structure.  replace 'Index' with the name of whatever column you want to sort the results by.  This is usually (but doesn't have to be) one of the indices.  You probably could eliminate the 'order by' statement all together, but it's pretty poor practice.

Link to comment
https://forums.phpfreaks.com/topic/113594-pagination/#findComment-583869
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.