PDA

View Full Version : Ultimate Fade-in slideshow (v2.4) PHP MySQL String



Disturbed
09-23-2013, 08:38 AM
1) Script Title: Ultimate Fade-in slideshow (v2.4)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm#.Uj_6Oz8SZNo

3) Describe problem:

Hello dear Dynamicles! I came across your script and I was amazed by its easiness when it came to display static pictures from a folder. But now, as we all know, things amongst programmers are NEVER simple.

I am trying to display images from an Array, the images in that array have a $photo_category that is = to the $id of a parent Item. I am trying to create slideshows automatically to each of those items by giving 1 string to the image array, the images are stored in a DB with a file location, and as images in a folder as well. Maybe with this bit of code you get a further understanding of the goal I am trying to accomplish :


$images = @mysql_query("SELECT photo_id, photo_filename, photo_caption FROM gallery_photos
WHERE photo_category = $id");
if (!$images) {
die('<p> Error retrieving Images from database!<br />' . 'Error: ' . mysql_error() . '</p>');
}

while ($image = mysql_fetch_array($images)) {
$photo_id = $image['photo_id'];
$photo_filename = $image['photo_filename'];
$photo_caption = $image ['photo_caption'];
$photo_category = $image ['photo_category'];
?>




<html>
<head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript" src="fadeslideshow.js">

/***********************************************
* Ultimate Fade In Slideshow v2.0- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>

<script type="text/javascript">

var mygallery2 = new fadeSlideShow({
wrapperid: "<?php $id ?>", //ID of blank DIV on page to house Slideshow
dimensions: [250, 180], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php ["cms/houses/$photo_filename", "", "", "$photo_caption"] ?>
],
displaymode: {type: 'manual', pause: 2500, cycles: 0, wraparound: false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "always",
togglerid: "fadeshow2toggler"
})

</script></head>
</html>

Many slideshows are displayed on the same page, as it is 1 page with a lot of content. Each slideshow should get the $id from the parent Item, as you can see in the wrapperid.
I hope I was able to explain my Idea well enough, if not, I will try to go in to further detail.

*Edit : Has anyone ever tried to archive something like this, or is it not possible to display a Slideshow from an Image Array that is selected from a DB query?

Thanks in Advance,
Dominik

jscheuer1
09-23-2013, 04:26 PM
I know next to nothing about database coding. I'm OK with PHP, and very good with javascript.

I'm sure it can be done. Unfortunately, given my knowledge of database code, I can't help you a lot with that part.

What you can do is load the page in the browser and use the browser's "View Source". That will show you what the server side code is getting resolved to. It should of course look like what the javascript code requires. If not you will have to figure out why not and fix it. Often there will be error messages from the server, or it might look OK but just have one or more javascript syntax errors in it. If the former, your database/PHP code has server side problems that must be addressed. If the latter, it's just how the PHP is formatting the output. Commas, quotes, braces, etc. must appear in the proper places as expected by the script. If it looks OK to you but is still not working, give me a link to it. I can probably spot the javascript syntax problem(s) and you can work back from there to fix how the output is being formatted.

Deadweight
09-23-2013, 05:29 PM
So let me get this right. Are you trying to display certain images, from your array, on certain pages from your database to be loaded at the bottom of this photo gallery?

Disturbed
09-27-2013, 07:03 AM
Yup Crazy, it is an information Accordion, that has an ID assigned to each accordion, each accordion is a <ul> element at the same time. Sooo : Gathering all the information already works like a charm, meaning the information of the article (ID, Summary, Content, etc...) because its pure PHP/MySQL and HTML, but as it seems, this script accepts only fixed values to display images. I wouldn't see it working to pass the ID of the element over with the wrapperid as I have tried there. It seems so incorrectly written.

Disturbed
10-19-2013, 07:05 PM
Anyone?

Disturbed
11-14-2013, 12:05 PM
Bump!

jscheuer1
11-16-2013, 04:22 PM
The key to any conversion from HTML/javascript to PHP/HTML/javascript is often to look at the served source code of the page. If the page isn't working as desired, while viewing it in the browser, use the browser's "View Source". That will show you how the PHP part is being replaced. If that doesn't fit the requirements of the script, the PHP must be changed so that it does.