Advanced Search

Results 1 to 10 of 10

Thread: jquery/ajax to load a big text file in real time

  1. #1
    Join Date
    Jul 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default jquery/ajax to load a big text file in real time

    Hi folks,

    One of our research project requires a real-time-updated (big!) text file to be loaded to a table for visualization. I am a researcher with some (very limited) basic coding and I thought of using javascripts/html/php to archive the goal. So far I was able to load a test text file (in real time) to a html table. Please check it here: http://grih.org:8888/test/refresh/. The test text is here: http://grih.org:8888/test/refresh/data.txt. The idea is pretty basic:

    1. use jquery to load changes made on the text file (index.html):
    HTML Code:
    <html>
    <head>
    <title>Demo Auto Load</title>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script>
      $(document).ready(function() {
        $("#responsecontainer").load("response.php");
        var refreshId = setInterval(function() {
          $("#responsecontainer").load('response.php?randval='+ Math.random());
        }, 9000);
        $.ajaxSetup({ cache: false });
      });
    </script>
    </head>
    <body>
    <h1>Data to be shown</h1>
    <div id="responsecontainer">
    </div>
    </body>
    </html>
    2. the response.php script will deal with the text file
    PHP Code:
    <?php
      $f 
    fopen ("data.txt""r");
      
    $ln0;
      echo 
    "<table  border='1'>";
      echo 
    "<tr><th>DATE</th><th>ID</th><th>Bla...</th><th>PHONE</th><th>Ble...</th><th>Messenger</th><tr>";
      while (
    $linefgets ($f)) {
        echo 
    "<tr>";
        ++
    $ln;
        
    $array explode("    ",$line);
        foreach(
    $array as $value){
          echo 
    "<td>".$value."</td>";
        }
        echo 
    "</tr>";
      }
      
    fclose ($f);
    ?>
    My questions are:

    + since in the real project, the text file will be big, and loading big file will give an ugly visualization of data. We want to do some other kinds of dynamic content so that for example, all data will be loaded to pages like the Ajax Pagination script, and the changes from text file will be shown in the first page. All other pages can be loaded later if users click on them.

    + is there a better way of doing this, with only html/javascript? I know a bit of php and coded some, so that's why I did it with the help of php.

    Thanks in advance,

    D.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,687
    Thanks
    43
    Thanked 3,129 Times in 3,095 Posts
    Blog Entries
    12

    Default

    Something like (requires PHP 5+ but could be adapted to PHP 4):

    PHP Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
    #dataArea td {
        padding: 0.5em;
    }
    .pages {
        display: block;
        float: left;
        margin: 0.5em 0.5em 0 0;
        background-color: lightyellow;
        border: 1px solid black;
        padding: 0.5em;
        width: 3.5em;
        text-align: center;
        text-decoration: none;
    }
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
        $.ajaxSetup({ cache: false });
        $('.pages').click(function(e){
            $('#dataArea').load(this.href);
            e.preventDefault();
        });
    });
    </script>
    </head>
    <body>
    <table>
    <tbody id="dataArea">
    <?php
    $file 
    file('data.txt'FILE_IGNORE_NEW_LINES);
    foreach(
    $file as &$row){
        
    $row explode("\t"$row);
        
    $row =  "<tr><td>" implode("</td><td>"$row) . "</td></tr>\n";
    }
    $files array_chunk($file10);
    echo 
    implode(''$files[0]);
    ?>
    </tbody>
    </table>
    <?php
    foreach($files as $num => $rows){
        
    file_put_contents("tablefile$num.htm"$rows);
        
    ?>
        <a class="pages" href="<?php echo "tablefile$num.htm"?>"><?php echo "Page " . ($num 1); ?></a> 
        <?php
    }
    ?>
    </body>
    </html>
    Note: This line:

    Code:
    $files = array_chunk($file, 10);
    That's the number of rows per page.
    Last edited by jscheuer1; 06-11-2013 at 12:57 PM. Reason: info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    dukevn (06-12-2013)

  4. #3
    Join Date
    Jul 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    Something like (requires PHP 5+ but could be adapted to PHP 4):
    John, its you again . Thanks so much for your response. Anyway, I got it working partially at the following page: http://grih.org:8888/test/refresh/john.php

    Unfortunately the feature of automatically loading data's changes (without refreshing the page) is gone. I had to refresh the page to see new changes applied and appeared.

    In the index.html, I think the following code does that task:
    Code:
      $(document).ready(function() {
        $("#responsecontainer").load("response.php");
        var refreshId = setInterval(function() {
          $("#responsecontainer").load('response.php?randval='+ Math.random());
        }, 9000);
        $.ajaxSetup({ cache: false });
      });
    which basically reload the response.php every 9 second into the data div. Is there a way to adapt that mechanism into the corresponding code in your john.php?
    Code:
    jQuery(function($){
        $.ajaxSetup({ cache: false });
        $('.pages').click(function(e){
            $('#dataArea').load(this.href);
            e.preventDefault();
        });
    });
    Thanks,

    D.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,687
    Thanks
    43
    Thanked 3,129 Times in 3,095 Posts
    Blog Entries
    12

    Default

    OK:

    PHP Code:
    <?php
    $refresh 
    = isset($_GET['refresh']);
    if(!
    $refresh){
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
    #dataArea td {
        padding: 0.5em;
    }
    .pages {
        display: block;
        float: left;
        margin: 0.5em 0.5em 0 0;
        background-color: lightyellow;
        border: 1px solid black;
        padding: 0.5em;
        width: 3.5em;
        text-align: center;
        text-decoration: none;
    }
    .pages.activepage, .pages:hover {
        border-color: red;
    }
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
        $.ajaxSetup({ cache: false });
        var $pages = $('.pages').click(function(e, override){
            if(!$(this).hasClass('activepage') || override === 'override'){
                $('#dataArea').load(this.href);
                $pages.removeClass('activepage').filter(this).addClass('activepage');
            }
            e.preventDefault();
        });
        $pages.eq(0).addClass('activepage');
        setInterval(function(){
            $.ajax({
                url: '<?php echo $_SERVER['PHP_SELF']; ?>',
                data: {refresh: 'true'},
                success: function(){
                    $('.pages.activepage').trigger('click', ['override']);
                }
            });
        }, 9 * 1000);
    });
    </script>
    </head>
    <body>
    <table>
    <tbody id="dataArea">
    <?php
    }
    $file file('data.txt'FILE_IGNORE_NEW_LINES);
    foreach(
    $file as &$row){
        
    $row explode("\t"$row);
        
    $row =  "<tr><td>" implode("</td><td>"$row) . "</td></tr>\n";
    }
    $files array_chunk($file10);
    if(!
    $refresh){
    echo 
    implode(''$files[0]);
    ?>
    </tbody>
    </table>
    <?php
    }
    foreach(
    $files as $num => $rows){
        
    file_put_contents("tablefile$num.htm"$rowsLOCK_EX);
        if(!
    $refresh){
        
    ?>
        <a class="pages" href="<?php echo "tablefile$num.htm"?>"><?php echo "Page " . ($num 1); ?></a> 
        <?php
        
    }
    }
    if(!
    $refresh){
    ?>
    </body>
    </html>
    <?php
    }
    ?>
    Notes:

    Added border color change for hover of the .pages links and for the active page, see style section in the above code.

    This line (highlighted):

    Code:
    jQuery(function($){
    	$.ajaxSetup({ cache: false });
    	var $pages = $('.pages').click(function(e, override){
    		if(!$(this).hasClass('activepage') || override === 'override'){
    			$('#dataArea').load(this.href);
    			$pages.removeClass('activepage').filter(this).addClass('activepage');
    		}
    		e.preventDefault();
    	});
    	$pages.eq(0).addClass('activepage');
    	setInterval(function(){
    		$.ajax({
    			url: '<?php echo $_SERVER['PHP_SELF']; ?>',
    			data: {refresh: 'true'},
    			success: function(){
    				$('.pages.activepage').trigger('click', ['override']);
    			}
    		});
    	}, 9 * 1000);
    });
    controls the frequency of the update. Here 9 seconds (9 times 1000 milliseconds) But, in actual practice, if a lot of people are viewing the page, there would be more frequent updates because an interval would be established for each visitor and they would likely be firing off at various times. It might be a better idea to make the updating (the part that writes the separate pages) a 'chron job'. I'm not sure how to do that yet. Or we could make a flag file that disappears when a user leaves the page to tell this page whether or not to set up its own interval, but that could get messy because it would have to check periodically if that flag disappeared, make its own at that point and set up its own interval. I'll think about it.

    For now I've added the LOCK_EX flag to the file_put_contents() function so that if two visitors try to write at the same time, that should at least prevent file corruption.

    If this is more for internal use by an organization and not too many people would be viewing it at one time, more frequent updates are probably not a big issue. The LOCK_EX flag should be all that's required to deal with it.
    Last edited by jscheuer1; 06-12-2013 at 02:36 AM. Reason: minor code improvement
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    dukevn (06-12-2013)

  7. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,297
    Thanks
    28
    Thanked 135 Times in 130 Posts
    Blog Entries
    28

    Default

    It took me some time to find out how John's solution works. I then thought it might be possible without PHP. I created a text file (data.txt) and put 'arie' in it. I also created a html file (index.html) and put the following in it:
    Code:
    <div id="responsecontainer"></div>
    <!-- Invisible iframe used to write content to the div (ajax replacement)  -->
    <iframe style="position: absolute; width:10px; left: -15px" onload="tthis=this; setInterval('document.getElementById(\'responsecontainer\').innerHTML=tthis.contentWindow.document.body.textContent; tthis.src=\'data.txt\'',4000)"></iframe>
    I opened index.html and there it was (in index.html), after 4 seconds: 'arie'.
    Then I added 'molendijk' to the text file. After 4 seconds, my index.html showed 'arie molendijk', which proves that the content in index.html was dynamically changed in real time.
    Last edited by molendijk; 06-11-2013 at 10:53 PM. Reason: Correction

  8. The Following User Says Thank You to molendijk For This Useful Post:

    dukevn (06-12-2013)

  9. #6
    Join Date
    Jul 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1 View Post
    OK:

    PHP Code:
    <?php
    ...
    ?>
    Notes:

    Added border color change for hover of the .pages links and for the active page, see style section in the above code.

    This line (highlighted):

    Code:
    jQuery(function($){
    ...
    });
    controls the frequency of the update. Here 9 seconds (9 times 1000 milliseconds)
    John, the updated code works perfectly!
    Quote Originally Posted by jscheuer1 View Post
    But, in actual practice, if a lot of people are viewing the page, there would be more frequent updates because an interval would be established for each visitor and they would likely be firing off at various times. It might be a better idea to make the updating (the part that writes the separate pages) a 'chron job'. I'm not sure how to do that yet.
    You are absolutely right about this. I also think that creating htm chunks for each viewer is not as good as having "fixed" htm chunks for all viewers (meaning viewers can only view, not create) - this also probably helps in security. In our real project, there is a unix bash script which is called by an unix daemon if there is new data. This bash script then appends new data to the data.txt file. I can modify that bash code so that after appending to data.txt, it will delete old htm chunks (if created before) and create new ones using the updated data.txt. The php/html/javascript simply loads it up for visualization.

    Now that it sounds much more like the Ajax Pagination script, but I prefer to learn from your codes.
    Quote Originally Posted by jscheuer1 View Post
    Or we could make a flag file that disappears when a user leaves the page to tell this page whether or not to set up its own interval, but that could get messy because it would have to check periodically if that flag disappeared, make its own at that point and set up its own interval. I'll think about it.

    For now I've added the LOCK_EX flag to the file_put_contents() function so that if two visitors try to write at the same time, that should at least prevent file corruption.
    I dont really understand neither the "flag" part you mentioned nor the LOCK_EX flag. Does it like a "write" and "read" permission flags in unix system?
    Quote Originally Posted by jscheuer1 View Post
    If this is more for internal use by an organization and not too many people would be viewing it at one time, more frequent updates are probably not a big issue. The LOCK_EX flag should be all that's required to deal with it.
    The real project can be huge, but I doubt there will be many people view the page at the same time. Anyway, learning different solutions and "playing safe" are always good, right?

    We are going to have the real system in the next few days and I gonna test what you suggested. I will post back the results for sure.
    Last edited by dukevn; 06-12-2013 at 04:55 AM. Reason: Added infos

  10. #7
    Join Date
    Jul 2008
    Posts
    33
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by molendijk View Post
    It took me some time to find out how John's solution works. I then thought it might be possible without PHP. I created a text file (data.txt) and put 'arie' in it. I also created a html file (index.html) and put the following in it:
    Code:
    <div id="responsecontainer"></div>
    <!-- Invisible iframe used to write content to the div (ajax replacement)  -->
    <iframe style="position: absolute; width:10px; left: -15px" onload="tthis=this; setInterval('document.getElementById(\'responsecontainer\').innerHTML=tthis.contentWindow.document.body.textContent; tthis.src=\'data.txt\'',4000)"></iframe>
    I opened index.html and there it was (in index.html), after 4 seconds: 'arie'.
    Then I added 'molendijk' to the text file. After 4 seconds, my index.html showed 'arie molendijk', which proves that the content in index.html was dynamically changed in real time.
    I am not a coder, but from what I understand, you are loading an iframe onto a div, and in turns the iframe loads and refreshes its data - the data.txt file - using html refresh mechanism. If the data.txt is big, the load/refresh can be very long. Not to mention that converting from txt to html table will create large html size. I remember I tried to load about 1k-2k lines from a text file to a html table and the browser seemed to be frozen.

  11. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,687
    Thanks
    43
    Thanked 3,129 Times in 3,095 Posts
    Blog Entries
    12

    Default

    I can modify that bash code so that after appending to data.txt, it will delete old htm chunks (if created before) and create new ones using the updated data.txt.
    That would be the way to go. In fact, it should be used to create the chunks in the first place. So that part of the PHP code would be dropped from the page. Instead of creating the files, PHP would only count them to determine how many .pages links there should be. That could be done either by parsing the main data.txt file as an array like we're doing now into the same chunk size as the bash script uses, without writing the files, or by actually counting the chunk files the bash script makes. I think parsing the data.txt file would be more efficient, maybe even just counting its lines. Then, instead of PHP writing the chunks (bash has already done that), have javascript update the number of .page links if different than before on the basis of PHP reporting how many that there need to be. When each chunk file is fetched via AJAX, it will be the current one created by bash because the AJAX routine is set to not cache the responses.

    So we would still set an interval of 9 seconds (or less or more), but simply to check if the data.txt file has changed by having recorded its file date and time on page load as a reference, and comparing and updating that each time the interval fires, and if it has changed, then count the chunks, update the nav if required, and refresh the currently displaying chunk just in case it has changed. Again, any other chunks that are then fetched via AJAX will be the current ones because we're not caching them.

    When I get a bit of time, I will write that all up.

    One thing puzzles me though. You say that bash will add to the data.txt file. Do you mean that literally? I mean, does the old data ever get taken away or changed? If not, we don't ever have to update the currently displaying chunk file. But it defies logic to think that old data would never change or be removed, so I think we should keep that part anyway, even if it's not anticipated to be frequently needed.

    Oh, and I almost forgot - the LOCK_EX flag means lock exclusive, so that while writing to the file, no other process may write to the file. It's not so much a flag as an argument or parameter of the file_put_contents function. PHP calls it a flag though. If bash is doing the writing, though, there's no need to be concerned with that. The other flag I mentioned would be a file we would create in an attempt to keep track of whether or not an update loop is already in process when a given user loads the page and if so not to initialize a new one. But if bash does the updating of the chunks, a flag file for that would no longer be needed.

    One more thing though before I could write that, will bash be making the the td tags in the chunk flies:

    PHP Code:
    foreach($file as &$row){
        
    $row explode("\t"$row);
        
    $row =  "<tr><td>" implode("</td><td>"$row) . "</td></tr>\n";

    Or will javascript have to do that now?
    Last edited by jscheuer1; 06-12-2013 at 09:29 AM. Reason: almost forgot
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  12. #9
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,297
    Thanks
    28
    Thanked 135 Times in 130 Posts
    Blog Entries
    28

    Default

    Quote Originally Posted by dukevn View Post
    I am not a coder, but from what I understand, you are loading an iframe onto a div, and in turns the iframe loads and refreshes its data - the data.txt file - using html refresh mechanism. If the data.txt is big, the load/refresh can be very long. Not to mention that converting from txt to html table will create large html size. I remember I tried to load about 1k-2k lines from a text file to a html table and the browser seemed to be frozen.
    I changed my code a little bit. It works better now. There's a demo HERE.
    I extract the contents of a hidden iframe with src=data.txt and write them onto the div. The iframe refreshes at regular intervals, ensuring that the div always contains the latest data.
    I don't have a javascript-mechanism comparable to the PHP-fgets, so the text file is not converted to a html table.
    But I made sure that the data are readable enough by putting them inside pre-tags.
    Index.html looks like this:
    Code:
    <!doctype html>
    <html >
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title></title>
    <style>
    pre{font-family: verdana; font-size:13px; }
    </style>
    </head>
    <body >
    <h1>Data to be shown</h1>
    (change the data in <i>data.txt</i> and see what happens within 9 secs)<br>
    <div id="responsecontainer" ></div>
    <iframe id="responsecontainer_iframe" style="position: absolute; width:10px; left: -15px; display: none" src="data.txt" onload="document.getElementById('responsecontainer').innerHTML='<pre>'+this.contentWindow.document.body.textContent+'<\/pre>';tthis=this; setInterval('document.getElementById(\'responsecontainer\').innerHTML=\'<pre>\'+tthis.contentWindow.document.body.textContent+\'<\/pre>\'; tthis.src=\'data.txt\'',9000)"></iframe>
    </body>
    </html>
    And here's data.txt.
    Maybe this is not exactly what you want. You can always rely on John's code. He knows much more about these things than I do.
    Last edited by molendijk; 06-12-2013 at 02:51 PM. Reason: Added link to data.txt

  13. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,687
    Thanks
    43
    Thanked 3,129 Times in 3,095 Posts
    Blog Entries
    12

    Default

    I've been playing around with this. I think that it would be a good idea to have the bash script write/overwrite a flag file when it's finished making the new chunks and to use that, rather than the main data.txt as the file for the live page to look at to tell it when things have updated. That way we should be able to avoid a situation where the data.txt file has been updated but the chunks haven't all been updated yet.

    A fine point. For now I have it working off of the data.txt file, like so:

    PHP Code:
    <?php
    $refresh 
    = isset($_GET['refresh']);
    $datapage 'data.txt'//can include SERVER path to the data file if different than this page's
    $chunksize 10//number of lines in each chunk file
    //Each chunk file created by bash should have a file name of $chunkprefixSOMENUMBER$chunkext
    //with SOMENUMBER starting at 0 and going sequentially from there
    $chunkprefix 'tablefile'//can include WEB path to the chunk files if different than this page's
    $chunkext '.htm';
    $filetime filemtime($datapage);
    if(!
    $refresh){
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
    #datatable th, #datatable td {
        border: 1px solid orange;
    }
    #datahead th {
        color: red;
        padding: 0.25em
    }
    #datahead1 {
        width: 6em;
    }
    #dataArea td {
        padding: 0.5em;
    }
    .pages {
        display: block;
        float: left;
        margin: 0.5em 0.5em 0 0;
        background-color: lightyellow;
        border: 1px solid black;
        padding: 0.5em;
        width: 3.5em;
        text-align: center;
        text-decoration: none;
    }
    .pages.activepage, .pages:hover {
        border-color: red;
    }
    </style>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script type="text/javascript">
    jQuery(function($){
        $.ajaxSetup({ cache: false });
        function pagefunction(e, override){
            if(!$(this).hasClass('activepage') || override === 'override'){
                $('#dataArea').load(this.href);
                $pages.removeClass('activepage').filter(this).addClass('activepage');
            }
            e.preventDefault();
        }
        var $pages = $('.pages').click(pagefunction), filetime = <?php echo $filetime?>, $wrap = $pages.parent();
        $('#tablecontainer').height($('#tablecontainer').height());
        $('#update').text('<?php echo date ("F jS, Y g:ia T"$filetime); ?>');
        $pages.eq(0).addClass('activepage');
        setInterval(function(){
            $.ajax({
                url: '<?php echo $_SERVER['PHP_SELF']; ?>',
                data: {refresh: 'true'},
                success: function(data){
                    data = data.split('^');
                    if(filetime == data[0]){
                        return;
                    }
                    filetime = data[0];
                    $('#update').text(data[2]);
                    var $active = $('.pages.activepage'), numpages = $pages.length, i = -1, activeindex = $pages.index($active);
                    if(numpages != data[1]){
                        $wrap.empty();
                        while(++i < data[1]){
                            $wrap.append('<a class="pages" href="<?php echo $chunkprefix?>' + i + '<?php echo $chunkext?>">Page ' + (i + 1) + '</a>');
                        }
                        $pages = $('.pages').click(pagefunction);
                        activeindex = $pages.length > activeindex? activeindex : 0;
                    }
                    $pages.eq(activeindex).addClass('activepage').trigger('click', ['override']);
                }
            });
        }, 9 * 1000);
    });
    </script>
    </head>
    <body>
    Last Updated: <span id="update"></span>
    <div id="tablecontainer">
    <table id="datatable">
    <thead>
    <tr id="datahead"><th id="datahead1">Column 1</th><th id="datahead2">Column 2</th><th id="datahead3">Column 3</th><th id="datahead4">Column 4</th><th id="datahead5">Column 5</th><th id="datahead6">Column 6</th></tr>
    </thead>
    <tbody id="dataArea">
    <?php
    }
    $file file($datapage);
    $files array_chunk($file$chunksize);
    $pages count($files);
    $page = -1;
    if(!
    $refresh){
    include 
    $chunkprefix '0' $chunkext;
    ?>
    </tbody>
    </table>
    </div>
    <div>
    <?php
    while(++$page $pages){
        
    ?>
        <a class="pages" href="<?php echo "$chunkprefix$page$chunkext"?>"><?php echo "Page " . ($page 1); ?></a> 
    <?php
    }
    ?>
    </div>
    </body>
    </html>
    <?php
    } else {
        echo 
    $filetime '^' $pages '^' date ("F jS, Y g:ia T"$filetime);
    }
    ?>
    This assumes chunk files like:

    HTML Code:
    <tr><td>201212099</td><td>080956</td><td>00</td><td>0973517500</td><td>00</td><td>04813,1,49,G,071212,K</td></tr>
    <tr><td>20121112</td><td>161318</td><td>00</td><td>01675032799</td><td>00</td><td>11971,1,45,G,121112,K</td></tr>
    <tr><td>20121113</td><td>092155</td><td>00</td><td>0974522910</td><td>00</td><td>04900,1,78,T,121112,K</td></tr>
    <tr><td>20121113</td><td>092711</td><td>00</td><td>0974522910</td><td>00</td><td>04900,1,61,G,131112,K</td></tr>
    <tr><td>20121113</td><td>140032</td><td>00</td><td>01675032799</td><td>00</td><td>11971,1,21,G,131112,K</td></tr>
    <tr><td>20121113</td><td>140148</td><td>00</td><td>01675032799</td><td>00</td><td>11971,1,47,T,131112,K</td></tr>
    <tr><td>20121113</td><td>145753</td><td>00</td><td>01666723117</td><td>00</td><td>04828,1,47,G,121112,K</td></tr>
    <tr><td>20121113</td><td>145846</td><td>00</td><td>01666723117</td><td>00</td><td>04828,1,41,G,131112,K</td></tr>
    <tr><td>20121113</td><td>150631</td><td>00</td><td>01675032799</td><td>00</td><td>11971,1,09,T,131112,K</td></tr>
    <tr><td>20121113</td><td>192056</td><td>00</td><td>0974958709</td><td>00</td><td>04900,1,43,G,131112,K</td></tr>
    If you have any problem outputting chunks like that, let me know. However, it would be best to use the above format.

    Also - The bash need not delete the old chunk files, though it can. All it has to do is overwrite them. Any extra ones (like if there end up being less chunks after an update) will be ignored by this script.

    Added Later:

    I played around with this a bit more. This time with a flag file. It really is the way to go because it can hold the new number of chunk files - all the live page needs to know in order to update, which saves a lot of time when refreshing. I have it worked out, along with a PHP version of what the bash would need to do. If you're interested, let me know.
    Last edited by jscheuer1; 06-13-2013 at 08:07 PM. Reason: Added Later
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Real time jQuery notifications from a form?
    By xiphoid in forum JavaScript
    Replies: 5
    Last Post: 03-10-2013, 11:29 AM
  2. Replies: 4
    Last Post: 08-26-2012, 02:21 PM
  3. How to make sure Javascript file load each time
    By lena in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 07-23-2012, 04:27 PM
  4. Dynamic Ajax Content loading a file upon file load, rather than a link.
    By TrueKnight in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 05-12-2008, 10:10 AM
  5. Real time hit counter
    By kwahamot in forum Flash
    Replies: 6
    Last Post: 01-16-2008, 01:50 AM

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
  •