In my php script i have an object->function which will check the database and return an array of people who are logged within last certain time(say last 5 minutes). THis info is displayed as the page loads ofcourse. (so far working fine)

What I am trying to do is get this array of logged people every say 5 minutes by calling that function and displaying it in the page like using javascript settimeout function even though the page is idle ie without having to refresh or reloading the current page.

I am only assuming perhaps this is possible since with javascript using settimeout you can change color of a div or picture with rest of the content on the page remaining the same.

It would be great help if someone could give me a solution.
Thanks
masikwha

    Like you said, use Javascript to refresh a frame every 5 minutes.

    PHP is a server-side language, it can't manipulate things client-side. Javascript is the opposite.

      Thanks for you response Brad. I know about using meta tag to refresh or onload = window.settimeout("url", time).
      But this method reloads the whole page, which is not what i want to happen.

      Solution I am looking for id only to call a php object function to display in a html <td> or say <div>
      <td>Logged:
      <?php for($i = 0; $i < count($loglist); $i++) print $loglist[$i] . " "; ?>
      </td>

      with meta-tag above works fine, but its reloading the whole page at the same time.

      Is there a way that I can use onLoad=setTimeOut("call php function", time) to do the same without having to load the whole page?? I guess my question is, if there is a way to call php function from java?? not sure if this is a ridiculous question lol

      Perhaps I could get the list from database using javascript , so I could call that function using jscript using setTimeOut?
      If there is a solution please reply

      Thanks a lot
      masikwha

      let me jsut add this:
      what i am trying to is similar to this->
      as you are browsing on this forum, you see the other people logged which is displayed, right? but its based on your last refresh or mouse click? Same sort of display like on this forum but without having to reload the whole page but done under certain time interval jsut for that purpose of displaying the logged people and not the reload of whole page content!. As you can see, if you had to reload this page it would take long time to make all sql queries and other thing right?
      I guess this gives more clarity to what i am trying to do.
      thanks

        Traditionally php and javascript are independent of one another and cannot interact directly. (You can use php to write out some javascript, but php can't call a javascript function while it's executing and vise versa.) In which case writing out all needed info to javascript and letting javascript do all the work is the typical way.

        bradgrafelman mentioned using a frame, which would allow you to have only a portion of the page refresh. That might be what you're looking for.

        If you don't mind limiting your application to more recent browsers there is also the XMLHTTPRequest object you could use to simulate calling php from javascript. Jpspan is one way to do this from php, and makes it much easier to accomplish. (You can also simulate this method with an iframe for older browsers, but that is more difficult.)

          As I said, the easiest solution was to insert an (I)frame and reload that frame every xx seconds using Javascript.

          PHP is entirely server-side. You can't combine client-side scripting with server-side scripting without sending a request to the server (refreshing or using frames).

            Write a Reply...