Closed Thread
Results 1 to 10 of 10

Thread: increase value by 1 and reload

  1. #1
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    increase value by 1 and reload

    I am working on a photo gallery. in php. the code so far is thus:

    Code:
    <?php
                    
    //Connect to Database
                    
    include("userDbConnection.php");
                    
                    
    // select pictures from database
                    
    $pictureQuery="Select * from gallery";
                    
    $runPictureQuery=mysql_query($pictureQuery)or die("An Error has occured. We apologise for any inconveniance. <br /> <br /> The Following error has occured:<br />" mysql_error());
                    
    //set i to zero use to make array item
                    
    $i=0;
                    
    //read pictures into an array
                    
    while($getPictures=mysql_fetch_array($runPictureQuery))
                    {
                        
    $description[$i] = $getPictures['g_description'];
                        
    $pic[$i] = $getPictures['g_pic'];
                        
    $i++;
                    }
                    
    //set j to 0. this will be used to refrence the pictures in the pic array
                    
    $j=0;
                    
                    
    //display the image
                    
    echo "<center><br /><img src='gallery/" $pic[$j] . "' border=0 /></center><br />";
                    
    //display the description
                    
    echo "<center>" $description[$j] . "</center><br />";
                    
                    
                
    ?>

    I have not really ever done javascript before which is what i think is needed for this next part. I basically just want a button that says next that will increase $j by 1 and reload the picture and the description with the new value. any help would be appreciated

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    G33k is offline Newbie
    Join Date
    Nov 2009
    Location
    Lithuania
    Posts
    19
    Rep Power
    0

    Re: increase value by 1 and reload

    It's actually not javascript, but ajax. That's what you need. So just read simple ajax tutorial here: Using POST method in XMLHTTPRequest(Ajax) and I think you'll be able to do your work and if not, ask, I'll try to help.

  4. #3
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: increase value by 1 and reload

    hmmm. maybe. Thou correct me if I am wrong isn't Ajax used to retrieve information from the server? My script already has the data and I just want to go to the next value in the array that has already been made. (also note that ajax is javascript. not that it matters for our discussion)

  5. #4
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: increase value by 1 and reload

    But your array is in your php and won't be sent to the page so the JavaScript can't access it. But maybe your Javascript could set the image source to "/yourphppage.php?image=" + (imagenumber + 1), and then your php page is checking the GET input image and loads the image so the JavaScript could get it. But otherwise you would probably need ajax.

  6. #5
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: increase value by 1 and reload

    ok. I think i will look into getting javascript to open a directory and read all the file names from it so i can display pics that way.

    Thanks guys

  7. #6
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: increase value by 1 and reload

    to do that, you need an xml or json to read the information from...
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  8. #7
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: increase value by 1 and reload

    i don't know but i found this which is working great: Dynamically populating a JavaScript image slideshow

  9. #8
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: increase value by 1 and reload

    But didn't you want the images from a database?

  10. #9
    zeroradius's Avatar
    zeroradius is offline Speaks fluent binary
    Join Date
    Feb 2008
    Location
    Ohio
    Posts
    1,403
    Rep Power
    25

    Re: increase value by 1 and reload

    yes, but only so it could have a description with it. I don't mind giving the description the axe

  11. #10
    Join Date
    Apr 2009
    Location
    Uppsala, Sweden
    Posts
    9,547
    Blog Entries
    5
    Rep Power
    98

    Re: increase value by 1 and reload

    I tried it fast and come up with this: http://vswe.codecall.net/Image%20Browser/
    It is storing the images in a database, if you want to use a data base I could give you the code which you can modify to make it better. Or you can jsut stick with the one you have

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. problem iframes reload
    By ramo2712 in forum ASP, ASP.NET and Coldfusion
    Replies: 1
    Last Post: 05-14-2011, 01:01 PM
  2. Anyone know how to reset or reload JFrame ?
    By xxxxjayxxx in forum Java Help
    Replies: 6
    Last Post: 05-10-2011, 09:45 AM
  3. Replies: 1
    Last Post: 04-19-2011, 08:47 AM
  4. jQuery function won't run after DIV reload
    By sparkles in forum JavaScript and CSS
    Replies: 1
    Last Post: 11-27-2010, 10:02 PM
  5. Page Reload
    By Divya in forum PHP Development
    Replies: 0
    Last Post: 03-23-2009, 04:49 AM

Tags for this Thread

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