Ben sayfa başına bir resmi görüntülemek için inşa edilmiş PHP basit bir galeri sistemi kurdum. Benim URL parametresi sadece bir galeri değişken ve bir sayfa değişkeni kullanır ve görüntü çekmek için herhangi bir şekilde görüntü iD kullanmaz. Ben bir dostu URL yapmak benim htaccess ayarlarını kuruyveyaum Bunun nedeni:
http://mysite.com/images/1/
^ Benim MySQL sveyaguda ilk görüntüyü çeker misin
veya
http//mysite.com/images/12/
^ Benim MySQL sorguda 12. görüntüyü çeker misin
PHP sayfası sonra gibi görünecektir:
images.php?gallery=images&page=1
ve
images.php?gallery=images&page=12
The queries (simplified) would then look like this fveya each of the above:
Fveya the first image:
SELECT id, img_src
FROM pictures
WHERE gallery = images
ORDER BY date_added DESC
LIMIT 0, 1
ve fveya the 12th image:
SELECT id, img_src
FROM pictures
WHERE gallery = images
ORDER BY date_added DESC
LIMIT 11, 1
It's been wveyaking great but I ran into a problem now that I want to add a feature. I was hoping to display thumbnails of the ten most recently added images to the database no matter which gallery they belong to… i.e. this query:
SELECT id, gallery, img_src
FROM pictures
ORDER BY date_added DESC
LIMIT 10
Is there any way I can know which 'position' veya 'page' each image would be fveya the specific gallery so that I can create the link cveyarectly?
Fveya example, say the ten most recent thumbnails return 4 pictures from the gallery 'images', then 2 pictures from the gallery 'weddings', then 3 pictures from the gallery 'pveyatraits' ve then one mveyae image from the gallery 'images', so my links should then be:
http://mysite.com/images/1/
http://mysite.com/images/2/
http://mysite.com/images/3/
http://mysite.com/images/4/
http://mysite.com/weddings/1/
http://mysite.com/weddings/2/
http://mysite.com/pveyatraits/1/
http://mysite.com/pveyatraits/2/
http://mysite.com/pveyatraits/3/
http://mysite.com/images/5/
Thanks fveya any help. I'm sure I'm overlooking something stupid easy here but I'm hoping to do it most efficiently as far as programming goes. So far my thoughts are that when I'm looping through the output I have to somehow retain each gallery's 'image count' ve add one to this count each time an image of that gallery is added.