close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Recordset Help For Random Image From Galleries

Thread began 1/07/2011 3:43 pm by Timespider | Last modified 2/11/2011 2:08 pm by Jason Byrnes | 2414 views | 7 replies |

Timespider

Recordset Help For Random Image From Galleries

Hi, can someone help with the sql for selecting a random image from the pg1_gallery_images table. Here is what I have so far but when I check the image properties in the browser I am missing some stuff. I just want to show a random image without the gallery itself. I can show the image I just need to get the correct path.

SELECT CONCAT(file_prefix,'.', file_ext)
FROM pg1_gallery_images
ORDER BY Rand() LIMIT 1



Thanks Chris

Sign in to reply to this post

Jason ByrnesWebAssist

your query will need to return the galley id and image size as well:

SELECT CONCAT(gallery_id,'/',file_prefix,'_782p.', file_ext) as fileName
FROM pg1_gallery_images
ORDER BY Rand() LIMIT 1


then in the image tag, add the relative path to the images folder:

<img src="images/<?php echo $row_RecordsetName['fileName']; ?>" />
Sign in to reply to this post

Timespider

Thanks Jason, I think I'm almost there. My problem now is the query returns the gallery folder number not the name so I think I need a join on the other table & I think the title in that table is the folder name, is this correct to get the right path? Below is the query output & the number 6 should be the folder (I presume).

6/nina_782p.jpg



Can you help me a bit more to complete the join or syntax of the query?

Thanks Chris

Sign in to reply to this post

Jason ByrnesWebAssist

you dont need a join, the gallery images are stored in a folder that is named with a number.

look in the files system on your server, you will see in the images folder for the gallery, a folder named 6, with the gallery images inside it.

Sign in to reply to this post

Timespider

Thanks Jason. All working fine now. I just had to change

<img src="images/<?php echo $row_RecordsetName['fileName']; ?>" />

to this

<img src="../Powergallery/images/<?php echo $row_rsRandomImage['fileName']; ?>" />



as my images folder is in a folder called "Powergallery" & obviously my recordset is called "rsRandomImage"


I appreciate your help.

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

Yes, you do need to make those changes to fit your environment, glad to hear it is working.

Sign in to reply to this post

Timespider

A bit more advanced image linking

Hi Jason, everything is working but I have had some people asking to get to the actual image in the power gallery from the random ones they clicked on in another page, at the moment I am just sending them to the gallery & then they find the image themselves.

I thought I could pass a url parameter but noticed that it doesn't have one, when viewing images in PG.

I have made another table that has the page URLs (pg1_galleryurl_grl) so I can get to the gallery, but how do I show the actual image they clicked on.

Below is the sql I am now using, as I said it all works fine I just need to get to the actual image

SELECT CONCAT(gallery_id,'/',file_prefix,'_782p.', file_ext) as fileName,pg1_gallery_images.description,pg1_gallery.title,description, pg1_gallery_images.file_ext, pg1_gallery_images.gallery_id, pg1_gallery.id, pg1_gallery.title, pg1_galleryurl_grl.galleryurl_grl
FROM ((pg1_gallery_images LEFT JOIN pg1_gallery ON pg1_gallery.id=pg1_gallery_images.gallery_id) LEFT JOIN pg1_galleryurl_grl ON pg1_galleryurl_grl.idgallery_grl=pg1_gallery.id)
WHERE gallery_id != '3'
ORDER BY Rand() LIMIT 2



Regards Chris :)

Sign in to reply to this post

Jason ByrnesWebAssist

Yeah, that's not going to be supported in power gallery, it would take a lot of custom coding to accomplish.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...