UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 1st February 2010, 02:36 PM   #1 (permalink)
galahad
Registered User
 
Join Date: Apr 2005
Posts: 459
Using PHP with javascript slideshow

I'm trying to set up a Javascript slideshow but with images that are pulled from a mYSQL database using PHP.

For example:

PHP Code:
if (!empty($row['pic1']))
{
echo 
'<td><a href="images/carpictures/' $title16 '"><img src="images/carpictures/' $title16 '"  width="140" height="93"></a></td>';

- and so on, with a statement testing to see if an image exists in that field. If it does, it gets added to the page with all the images displayed as thumbnails.

What I want is to have the images bring up their larger version when hovered over, and launch a slideshow with an autoplay feature as well as the usual back / next / play / stop controls etc.

However all the slideshows I've seen (Javascript based) have the image names assigned manually to individual variables in the page header.

The problem being that my images are being generated by the PHP call to the database.

Anyone know how I can get a Javascript slideshow working within this context- or know of one which actually does work with PHP?

(I was using Lightbox, which is great, except that the client doesn't like it so I can't use it...)
galahad is offline   Reply With Quote
Old 1st February 2010, 04:37 PM   #2 (permalink)
L Plates
Senior Member
 
Join Date: Jan 2003
Location: Wales
Posts: 443
Have javascript operate as php using htaccess and insert images into javascript with a php call
__________________
There is a very fine line between "hobby" and "mental illness."

North Wales Web Design
dbPoker
L Plates is offline   Reply With Quote
Old 17th February 2010, 03:19 PM   #3 (permalink)
crispibits
Penguin Botherer
 
Join Date: Feb 2006
Posts: 90
Use AJAX to get the image names

If I understand you correctly, you could use an Ajax call to your server asking for a list of images. Format the return as a JSON object:
"['foo.jpg','bar.jpg']"

You can then use something like prototype.js and it's handy .evalJSON() method to parse that into a Javascript array:

var imageArray = returnedValue.evalJSON();

imageArray[0] is foo.jpg
imageArray[1] is bar.jpg

You can now use that array for your slideshow.
Hope that makes sense!
Cheers,
Crispin
crispibits is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 06:34 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  SEO by vBSEO 3.0.0
Copyright © 1998-2009 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309