Image Gallery Help

They have: 16 posts

Joined: May 2006

I'm working on an image gallery that uses MySQL to store the URL's and information of images.

Right now, it shows all the images in the gallery on one page and I was trying to figureout how to split them into multiple pages.

Like: show image 1-10 on page 1, then image 11-21 on page 2 ect.

If anyone could give me any help on how to do this, that would be awsome,
Thanks!

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

You might do something like this (pseudo-code).

numperpage = 10;
page = urlparameter_page;

numtoskip = numperpage * (page - 1)

SQL = "select * from images limit numtoskip, numperpage";
execute(SQL);

if (page != 1)
{
prevpage = page - 1;
pagelink = '<a href="thisfile.php?page=' . prevpage . '>Previous</a>';
}

tempnumtoskip = numtoskip + numperpage;
tempSQL = "select * from images limit tempnumtoskip, numperpage";
execute(tempSQL);

if (any results)
{
nextpage = page - 1;
pagelink .= '<a href="thisfile.php?page=' . nextpage . '>Next</a>';
}
'

Does that pseudo-code make sense?

They have: 16 posts

Joined: May 2006

That makes a lot of sense.

Thanks for the help!

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

Not a problem. Let us know how it turns out. I'd love to see the link once you've modified it.

They have: 16 posts

Joined: May 2006

I finished modifying.

You can view the gallery here:
http://www.buschadventure.com/customgall/

Theirs still some modifications to be done, and it's not open to the public yet.

Thanks again for the help!

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

No problem. Looking good so far!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.