how can i make only a section of my code refresh

Discussion in 'HTML & Website Design' started by bobby9101, Apr 18, 2006.

  1. #1
    I have a .php file, and i would like only one part to reload as often as possible (i hvae a online visitors counter that needs constant updates)
    how can i do this?
     
    bobby9101, Apr 18, 2006 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    The easiest way is to have the part you want to refresh in an IFRAME with the meta refresh on the target document/page set to 1 second.
     
    digitalpoint, Apr 18, 2006 IP
  3. dotcomsdotbiz

    dotcomsdotbiz Banned

    Messages:
    73
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Create a small flash movie for your stat counter that is 30 seconds long and have it loadvars from a php file on your server. Its more seemloess and prettier then an IFRAME.

    Mike :)
     
    dotcomsdotbiz, Apr 18, 2006 IP
  4. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #4
    no other way?
    i was hoping there was a refresh function in php :( sorry i am a n00b
     
    bobby9101, Apr 18, 2006 IP
  5. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #5
    Yes, I agree with Shawn -- iframes or you can update some variables with JavaScript. I also use quite a bit of Java [Applets] to achieve the dynamic page [area] refreshing that you speak of. See the WiredPages link, below for some examples.

    PHP example -- I give the impression I am refreshing data using a PHP function inside an iframe. See this post as an example -- GEO Coder.

    Q...
     
    QiSoftware, Apr 18, 2006 IP
  6. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #6
    i wouldnt mind using JS
     
    bobby9101, Apr 18, 2006 IP
  7. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #7
    With JavaScript look into the onchange function associated with a form field. A good JavaScript reference book will show how it works.

    Q...
     
    QiSoftware, Apr 18, 2006 IP
  8. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi,

    You can use AJAX: make a PHP file that simply outputs the visitor count and nothing more, and request that in your JS by using the XMLHttpRequest object.

    If you want it to update on the user's pages as soon as the visitor count increases, in effect making a live counter, there are ways of simulating a persistent connection, but they can get quite tricky.

    - P
     
    penagate, Apr 18, 2006 IP
  9. QiSoftware

    QiSoftware Well-Known Member

    Messages:
    805
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    158
    #9
    Yes, AJAX is pretty impressive. However, right now the number of browsers supported is limited.

    See some of the AJAX demos offered here -- Open Rico. Make sure you have a browser that supports. [Latest release of Firefox].

    Q...
     
    QiSoftware, Apr 18, 2006 IP
  10. montel

    montel Banned

    Messages:
    113
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You would have to get some custom codeing for this might cost you a bit. try scriptlance.com
     
    montel, Apr 18, 2006 IP
  11. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #11
    The technology itself is relatively old. AJAX is just a new usage of it. I believe it's supported in all major browsers.

    - P
     
    penagate, Apr 19, 2006 IP