Results 1 to 4 of 4

Thread: Image Thumbnail Viewer II load from database

  1. #1
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Image Thumbnail Viewer II load from database

    Script: Image Thumbnail Viewer II
    Link: http://www.dynamicdrive.com/dynamici...thumbnail2.htm

    Hey everyone, I can't figure out how to set the image in the array to be retrieved from the database, is there any way I can do that? I managed to be able to get the thumbnails from my database, but for example...

    var dynimages=new Array()
    dynimages[0]=["image1.jpg", ""]
    dynimages[1]=["image2.jpg", ""]
    dynimages[2]=["image3.jpg", ""]

    I want to be able to get that value dynamically, i'm still learning javascript and asp.net so sorry if its a simple question, Thanks in advance!

    p.s. I like the fading effect

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can't do it with Javascript. However...

    Client side coding like javascript can't connect to a serverside database. You need serverside code/scripting.

    I don't like ASP, so here's an example in php... use asp if you so desire.

    Just an example, so won't fit exactly what you are doing, but it's a good start.
    PHP Code:
    //MORE JAVASCRIPT ABOVE...//
    var dynimages=new Array()
    <?php //connect to database here
    $query mysql_query("SELECT `URL` FROM `images`");
    while (
    $row mysql_row_assoc($query)) {
    echo 
    'dynimages['.$n.']=["'.$row['URL'].'", \"\"]';
    $n++;
    }
    ?>
    That will print a link of terms with increasing $n values for dynimages[0], dynimages[1], etc. with the URL from the database (table "images") as the url of the image.


    Make sense?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    May 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks djr33, looks easier in php than it would be in .net, I think I understand how to do it in .net, not just to figure out how to put it in code , thanks!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Good. There's more info at php.net on connecting to the database, etc.

    Perhaps you can use what you're used to but with the setup I have above. Not sure if it applies.

    good luck
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •