Progress Bar (Php/JS)

Discussion in 'PHP' started by gigamike, Jul 2, 2007.

  1. #1
    Guys,

    Im not sure if this is possible, im planning to have a progress bar on my module wherein im inserting data into a textfile. The creation and inseration of the textfile is quite long to generate and my user cant detetrmine if its already done. (The textfile im generating is a backup or .sql)

    Does anyone have an idea just even a moving image will do.

    Hoping for your help guys.

    Thanks,

    Mike
     
    gigamike, Jul 2, 2007 IP
  2. B.V.E.

    B.V.E. Peon

    Messages:
    106
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can make it all fancy with Ajax, but a simple Iframe should also solve your problem:
    * Divide the script in several steps
    * Use an iframe as a progress bar, i.e. just add something simple simple like a 1px border to make it look like an empty progressbar
    * The real php script will be loaded within the iframe and will echo/print the next Image block whenever a step has been completed...
    * You can echo a simple piece of javascript to navigate to a completely different page after all steps have been completed.

    [B]iframe.php[/B]
    [U]After each step:[/U]
    echo "<img src='./images/progress-block.gif' border='0'>";
    flush();
    
    [U]After all steps have been completed:[/U]
    echo "<script language='javascript' type='text/javascript'>
    	 <!--
    	  setTimeout('parent.document.location=\"done.php\"',500)
    	 // -->
     </script>"
    
    Code (markup):
    Make sure you adjust the width of the image blocks and iframe to the number of steps..

    I've used this method several times before in installers and it works like a charm :) Tested on Opera, Firefox & IE.
     
    B.V.E., Jul 2, 2007 IP
  3. gigamike

    gigamike Active Member

    Messages:
    165
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Hi B.V.E.,

    Ill try this one.

    Many Thanks,

    Mike

     
    gigamike, Jul 3, 2007 IP
  4. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #4
    B.V.E. suggested the same thing I would've.
     
    dp-user-1, Jul 3, 2007 IP