Web Analytics Made Easy -
StatCounter Auto play a recordset - CodingForum


No announcement yet.

Auto play a recordset

  • Filter
  • Time
  • Show
Clear All
new posts

  • Auto play a recordset

    I created a photo album using php and mysql. a simple recordset that has the next, previous, last, and first navigations. I was wondering is there a way to add a link that will auto play the recordset, like a slideshow?
    "Knowledge Speaks But Wisdom Listens"

  • #2

    Don't use "autoplay" for this, the word doesn't fits. You can't play a recordset...
    Btw, RecordSet is MS Access, or not?

    To your problem.
    I won't use php to solve this. The php script is finished when the site has loaded in the Browsers of your visitors.

    You can do this with JavaScript, loading the next image (or reloading the page with th nact image) with setTimeOut or, much easier, use the html tag to redirect the page after a couple of seconds.

    Something like this:

    <meta http-equiv="refresh" content="5; URL=<? echo $_SERVER['PHP_SELF']; ?>?image_id=<? echo $image_id+1; ?>">
    <!-- more head tags -->
    <!-- body content -->

    This will redirect after 5 seconds.



    • #3
      piz is right about the javascript, but i would use something more elaborate where you have 2 windows open with a
      <body onLoad="otherwindowname.location.reload();">
      so that the next photo is kinda preloaded in the other window wile this window is displayed.
      And then change the focus to the other window after x seconds

      Kinda like a real-live slideshow with two projectors so that you don't have delays in between.

      If you then plave the windows over eachother, the focuschange will look as if the foto is instantly replaced. If you place the windows next to eachoter, you will always see one page getting blank while the image is loaded, and while an image is displayed in the other window. When the image is loaded in the non-focused window, you'll have images in both windows

      With PHP, you can only use recordsetpaging with " LIMIT x, 1" where x is the ofset --> the number of the previous slide.
      But you'll still need the javascript for the auto-refresh so you could just as well try to have this proload-effect ...
      Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


      • #4
        Well I kninda understand. But what I wanted to do is have a button next to the recordset nav buttons that the viewer choose to can just press and have the recordset play like a slide show. I know if I do it the way of refreshing the viewer woluldn't have the choice of going through the pictures manually.
        "Knowledge Speaks But Wisdom Listens"


        • #5
          why not? You could just as well include a link to one of the images, that closes the other window and load the image in your active window without the <body onoad etc> tag.

          You could set the desired <body> depening on a querystringvariable that is only set if the user hits a link to an image or whatever.
          Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


          • #6
            I got it know. Thanx for your help.
            "Knowledge Speaks But Wisdom Listens"