I wish to use iframe with php to apply to my system. Firstly I will talk about what kind of page I wanted. I have a page showing the real time information. It use table to arrange the data, something like stock list. It got a countdown timer to refresh the data after 20 second. It only refresh the data, not reload the page.

From my opinion ( I don’t know correct or not ), it use iframe with php in the page,

test.html

<iframe name="testFrame" id="testFrame" scroll="no" src=""></iframe> 
<a href="execute.php" target="testFrame">Test it out</a> 

In execute.php file, it got a countdown timer also, maybe 10 second refresh a time to get the latest data, then post back to test.html without display the data directly. The countdown timer in test.html will refresh the data in the table after 20 second. Maybe add more rows or changing the data.

Anyone have face this kind of problem? Any comment can give me?
Thank to all for reply.

    You seem to be making things more complicated than necessary.

    Firstly, do not use src="". Set the src= to the page you want to be inside the iframe.

    Secondly, to refresh the iframe, you should not need a script, just use the HTTP header "Refresh" to do it (OR meta http-equiv).

    Make sure you don't use src="" otherwise you might end up creating an iframe loop with iframe inside iframe etc.

    Mark

      Make sure you set the cache to EXPIRE and NO-CACHE on both the main page and header in the iFRAME, sometimes internet explorer will simply stop honoring the meta refresh if you do not.

        thanks to reply...

        maybe is my english not very well, or i very hard to explain my problem to all of u.

        i used 2 file to show the page like stock list.
        File 1 - display.php
        File 2 - query.php

        query.php will auto select DB every 10 second, then post to display.php. User can press the refresh button or wait the 30 second countdown to display the newer data in display.php.

        In display.php, user will only see the data changing but not refreshing entire the page.

        is it more clearly for that? anyone can done it b4?

          check out my iframe example

          Not only has this been done before but it's a well accepted technique used by big java based systems. No reason by PHP can't do it too.

          Sarah

            5 days later

            thank u so much for reply. Finally i have done the thing what i want. But right now still have some problem need to solve it. I will explain wht i have done at here.

            display.php - display the data like stock list

            <script>
            function countDown(){
            countDownTime--;
            if (countDownTime <=0){
            countDownTime=countDownInterval;
            clearTimeout(counter)
            window.SearchFrame.location.replace("getdata.php"); 
            countDown()
            return
            }
            </script>
            
            <iframe style="width:0px; height:0px" marginwidth=0 marginheight=0 frameborder="no" name="SearchFrame" scroll="no" src=""></iframe> 
            
            <?
            sql statement ...........
            looping ........
            {
             $norow = mysql_num_rows($sql) ;
            echo'
            <script language="JavaScript1.2"> 
            function LoadTopFrame'.$norow.' (rowsnum3,Showwater)
            { 
               water'.$norow.'.innerText=Showwater;  
            } </script> ';
            <td><div align="center" id="water'.$norow.'"></div></td> }?>

            getdata.php

             sql statement - same as display.php
            looping......... { 
            <script language='Javascript'>     
            var Showwater = '<?php echo $showwater; ?>'; </script> <? echo' <script language="Javascript"> window.parent.LoadTopFrame'.$norow.'(rowsnum3,Showwater); </script> '; }?>

            The above code is the stupid way i doing right now. each time running

            • window.SearchFrame.location.replace("getdata.php");

            it will go to getdata.php to get the latest data without refresh the page, then pass back to display.php. It's work fine.

            The problem i face now was sometimes the data changing, javascript will prompt the error msg "object underfined"..
            This is the problem i need to solve it first.

              Write a Reply...