Advanced Search

Results 1 to 3 of 3

Thread: How dynamically generate image source for Ultimate Fade-in slideshow with PHP/MySQL

  1. #1
    Join Date
    Jul 2009
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default How dynamically generate image source for Ultimate Fade-in slideshow with PHP/MySQL

    1) Script Title: Ultimate Fade-in slideshow (v1.5)
    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...nslideshow.htm

    3) Describe problem:
    I REALLY like this script!
    I am trying to set up Ultimate Fade-in slideshow so I can dynamically generate the first section of the script:

    Code:
    var fadeimages=new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    fadeimages[0]=["photo1.jpg", "", ""] //plain image syntax
    fadeimages[1]=["photo2.jpg", "http://www.cssdrive.com", ""] //image with link syntax
    fadeimages[2]=["photo3.jpg", "http://www.javascriptkit.com", "_new"] //image with link and target syntax
    using PHP/MySQL. What I have done is the following:

    Code:
    <script type="text/javascript">
    
    /***********************************************
    * Ultimate Fade-In Slideshow (v1.51):  Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/
    
    var fadeimages=new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    <?php
    
    /*$cat = mysql_real_escape_string($_GET['cat']);*/
    $cat='all';
    
    $get_items = "SELECT * FROM poj_products WHERE cat='$cat'";
    $get_items = mysql_query($get_items);
       while($item_row = mysql_fetch_assoc($get_items));
       {
       extract($item_row);
       echo 'fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/'.$item_row['img-no_path'].'", "", ""]';
       }
    ?>
    
    var fadebgcolor="white"
    
    ////NO need to edit beyond here/////////////
    . . .
    but it does not seem to be working? Thank you, I would appreciate any help I can get :-) !

  2. #2
    Join Date
    Jul 2009
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    It works if I don't use the loop, such as:

    Code:
    <?php
    /*$cat = mysql_real_escape_string($_GET['cat']);*/
    $cat='all';
    $get_items = "SELECT * FROM poj_products WHERE cat='$cat'";
    $get_items = mysql_query($get_items);
       $item_row = mysql_fetch_assoc($get_items);
       extract($item_row);
       echo 'fadeimages[0]=["http://www.patternsofjoy.com/images/thumbs/'.$item_row['img-no_path'].'", "", ""]';
    ?>
    but it only show the first record in the DB in the 'cat' field (but it is not looping through the other items in the DB).

    Does anybody know how to fix this or is there another method by which I should atte4mpt to do this?

  3. #3
    Join Date
    Jul 2009
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    OK...got it!

    If you change the code and do something like this, it works:

    Code:
    <script type="text/javascript">
    
    /***********************************************
    * Ultimate Fade-In Slideshow (v1.51):  Dynamic Drive (http://www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit http://www.dynamicdrive.com/ for this script and 100s more.
    ***********************************************/
    
    var fadeimages=new Array()
    //SET IMAGE PATHS. Extend or contract array as needed
    <?php
    /*$cat = mysql_real_escape_string($_GET['cat']);*/
    $cat='all';
    $get_items = "SELECT * FROM poj_products WHERE cat='$cat'";
    $get_items = mysql_query($get_items);
    $i = 0;
    while($item_row = mysql_fetch_assoc($get_items))
    {
       extract($item_row);
       echo 'fadeimages['.$i.']=["http://www.patternsofjoy.com/images/thumbs/'.$item_row['img-no_path'].'", "", ""]' . "\n";
       $i++;
    }
    ?>
    
    
    var fadebgcolor="white"
    
    ////NO need to edit beyond here/////////////
    . . .

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •