SitePoint Sponsor

User Tag List

Results 1 to 18 of 18
  1. #1
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP - Page Loading... Please be Patient (???)

    Hi,

    How do you get it to say "Page Loading... Please be Patient" while the information from your database is being loaded, and once it is completed the statement disappears?

    Any help would be appreciated...

    Thanks,

    Doug

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which web server are you using?

  3. #3
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unix

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unix is an Operating System (like Windows) the webserver is probably Apache

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apache Sorry...

  6. #6
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Back again (I was reading another thread), there's an option in Apache web server where you can send the content to the client (ie the visitor's browser) in pieces instead the whole page. Let me look at the manual, and I'll post it here.

  7. #7
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, there's a function, flush(), quoting PHP manual,
    Flushes the output buffers of PHP and whatever backend PHP is using (CGI, a web server, etc.) This effectively tries to push all the output so far to the user's browser.
    This function only works in UNIX OS (well that's in theory because I only have Win 98, soon I'm going to install Mandrake but that's another history..). So having this in mind why don't you try this script:

    PHP Code:
    <?
     
    echo "Page Loading... Please be Patient";
     
    flush();
     ... 
    MYSQL stuff here .... 
     ... 
    working ....
     ... 
    finish mySQL checking ...

     echo 
    "Process finished, Thanks for waiting";
     
    flush();
    ?>
    I think that doesn't work with all the browsers, and depends on your html code. Try it and tell us what happen.

  8. #8
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is this where I would put it?

    <?
    echo "Page Loading... Please be Patient";
    flush();

    mysql_connect("localhost","xxxxxxxx","xxxxxxx");
    mysql_select_db("thedatabase");
    $query = "SELECT * FROM my_domains WHERE priceb >= 99 ORDER BY name";
    $result = mysql_query($query);

    echo "<html><body bgcolor=\"#FFFFFF\"><table border=\"0\" align=\"center\" width=\"600\" cellspacing=\"0\" cellpadding=\"2\"><tr><td><b>Domain</b></td><td><b>Price</b></td></tr>";
    while($row = mysql_fetch_array($result))
    {
    $price = $row['priceb'];
    $domain = $row['name'];

    echo "<tr><td>$domain</td><td>$price</td><td><a href=\"mailto:$domain@mywebsite.com?subject=$domain\">Contact Us</a></td></tr>";
    }
    echo "Process finished, Thanks for waiting";
    flush();

    ?>
    </table>
    </body>
    </html>

  9. #9
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seems Ok. Have you try it?

  10. #10
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have tried it a bunch of different ways...

    I can get the Page Loading to come up, but it won't go away when the page is loaded. I must be doing something wrong.

    Anybody out there know what I am missing???

    Thanks for all your help Paul...

    Doug

  11. #11
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try if this script works,
    PHP Code:
    <?php
     
    echo "Page Loading... Please be Patient";
     
    flush();
     
    sleep(10);
     echo 
    "Process finished, Thanks for waiting";
     
    flush();
    ?>
    You're going to see the first line, and then after 10 seconds the other line must appear.

  12. #12
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does that... but the "Page Loading" text never goes away. What I was hoping it would do is blink "Page Loading" and then just disappear all together when it is loaded. I know I have seen that on many sites. I just can't find one right now of course...

    Thanks,

    Doug

  13. #13
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok a final shot,
    PHP Code:
    <?php
     
    print ("Page Loading... Please be Patient");
     
    flush();
     
    sleep(10);
     print(
    "Process finished, Thanks for waiting");
     
    flush();
    ?>
    BTW do you know which version of PHP are you using?

  14. #14
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, OF COURSE the "Page Loading..." thing is going to stay there! why wouldn't it? you echoed it to the browser, so why would the browser hide it? the only way you'd be able to hide it is if you used some dynamic HTML. have it do something to hide the message once the bottom of your page loads.

    EDIT: oh, Doug, when you see that on other sites, they're just using a refresh META tag to go to another page. it's not the same page w/ the message disappearing. you're talking about like when you do a search on these forums and it says "search in progress," right? yep, they're just redirecting the browser after a few seconds.

    i've wanted to do this too, but there's no good way that i've found.
    Last edited by DR_LaRRY_PEpPeR; Oct 6, 2001 at 19:52.
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  15. #15
    SitePoint Wizard Defender1's Avatar
    Join Date
    Apr 2001
    Location
    My Computer
    Posts
    2,808
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or it could be using flash.
    people use flash preloaders to preload the content and display a loading screen while it's loading.

    also, i "believe" javascript can do something like that.
    Defender's Designs
    I'm Getting Married!

    Not-so-patiently awaiting Harry Potter Book 7 *sigh*

  16. #16
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as Defender mentions... you could stick your message in a <div id="hangon">....</div> etc

    and then send a javascript with the second flush() to hide the div...

    echo "<script>document[hangon].style.visibility=hidden</script>";


    - not sure about the javascript reference to the div there but you get the idea.

  17. #17
    SitePoint Zealot m0h's Avatar
    Join Date
    Sep 2001
    Location
    Cairo, Egypt
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do this using DHTML

    here is the code for it:


    <!-- Put this code inside of your <HEAD> tag. -->


    <style type="text/css">

    #divLoadCont {
    position: absolute;
    width: 100%;
    height: 98%;
    top: 0;
    left: 0;
    background-color: white;
    layer-background-color: white;
    font-family: arial,helvetica;
    z-index: 100;
    }

    </style>

    <script type="text/javascript" language="JavaScript">

    function ccbrowsercheck(){
    this.ver=navigator.appVersion
    this.dom=document.getElementById?1:0
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
    this.ie4=(document.all && !this.dom)?1:0;
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
    this.ns4=(document.layers && !this.dom)?1:0;
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
    return this
    }

    bw=new ccbrowsercheck()

    function cchidediv(div){
    if(bw.bw){
    div="divLoadCont"
    obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?document[div]:0;
    obj.visibility='hidden'
    }
    }

    onload=cchidediv;

    </script>


    <!-- Put this code inside of your <BODY> tag. Make sure it is ABOVE all other body content. -->


    <script>

    if(bw.bw)
    document.write('
    <div id="divLoadCont">
    <table width="100%" height="95%" align="center" valign="middle">
    <tr>
    <td width="100%" height="100%" align="center" valign="middle">
    <h3>Loading Page....</h3>
    </td>
    </tr>
    </table>
    </div>
    ')

    </script>

    hope it help you!

  18. #18
    I LOVE THIS SITE ! ! ! DougD's Avatar
    Join Date
    May 2000
    Location
    San Diego, CA
    Posts
    463
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do I need to put any onLoad code in the Body tag?

    Thanks,

    Doug


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
  •