hello all,
I am trying to create an istock kind of pagination of pictures, I am trying to find out how to do this in php (using divs or tables? not sure which is more suitable)and mysql.(ps is it a bad idea to store pictures in mysql database). I have been searching all over the net for such a tutorial, but to no avail.
this is an example of what I am looking to do:
http://www.istockphoto.com/search/text/happy/filetype/photos/source/basic#799784f

I plan on storing large hi res pictures. I hope that made sense, thanks in advance :)

Member Avatar for diafol

Do you have any code of your own to share? If not, at least have a go in the first instance.

Do you have any code of your own to share? If not, at least have a go in the first instance.

I am not even able to figure out how to begin, that's why I was hoping someone could show me, where to start or show me a tutorial that does kinda the same thing. This is the first site I am trying to make on my own. Any advice?

Member Avatar for diafol

OK, but I'm not going to do it for you. If this is your first go, I'll keep it simple. More sophisticated examples exist using sessions, but I'll leave that for now.

LOGIC:

1. retrieve max no. records from the DB, decide on no. items per page and calculate no. of pages for the navigation.
2. create an array of numbers using range(1,$maxpages) that will act as labels for the nav.
3. check for a querystring parameter called 'id' by using $_GET.
check for nos < 1, nos > maxpages, not integers etc and decide what to do with them - force the currentpage to a certain number or assign the id as currentpage if it exists in the array (step 2).
4. build the nav with a loop (foreach) when the currentpage is met, assign a blank label for this as opposed to a link (<a> tag).

Each link will have its querystring, e.g. href="?id=<?php echo $i;?>" .

That should enable you to set up a list of 'flat links'.

The textbox and nav buttons will be just as easy, but they need some js to help them (onclick). The buttons in particular will need to be given 1,currentpage0-1,currentpage+1,lastpage type values from php, but take care when you reach the first or last page as you then do not want to be able to -1 or +1 them. I usually disable those buttons (<< and < when I'm on page #1 and > and >> when on the last page).

A little bit of thinking is required for the displaying of the number of adjacent and remote links either side of the current page, e.g.
1 2 ... 45 46 47 48 49 ... 71 72

OK, but I'm not going to do it for you. If this is your first go, I'll keep it simple. More sophisticated examples exist using sessions, but I'll leave that for now.

LOGIC:

1. retrieve max no. records from the DB, decide on no. items per page and calculate no. of pages for the navigation.
2. create an array of numbers using range(1,$maxpages) that will act as labels for the nav.
3. check for a querystring parameter called 'id' by using $_GET.
check for nos < 1, nos > maxpages, not integers etc and decide what to do with them - force the currentpage to a certain number or assign the id as currentpage if it exists in the array (step 2).
4. build the nav with a loop (foreach) when the currentpage is met, assign a blank label for this as opposed to a link (<a> tag).

Each link will have its querystring, e.g. href="?id=<?php echo $i;?>" .

That should enable you to set up a list of 'flat links'.

The textbox and nav buttons will be just as easy, but they need some js to help them (onclick). The buttons in particular will need to be given 1,currentpage0-1,currentpage+1,lastpage type values from php, but take care when you reach the first or last page as you then do not want to be able to -1 or +1 them. I usually disable those buttons (<< and < when I'm on page #1 and > and >> when on the last page).

A little bit of thinking is required for the displaying of the number of adjacent and remote links either side of the current page, e.g.
1 2 ... 45 46 47 48 49 ... 71 72

WOW, not sure I understood all that but, I will reread several times, then make an attempt, I will let you know how I am going. Thanks for the help much appreciated. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.