-2

I want to reload my web page automatically if new row insert or delete any row or update.

I want to check it every 30 munite.

if new if new row insert or delete any row or update then reload my website.

<ul>
    foreach($output['result'] as $key => $val) {

                print'<li data-artist="'.$val['artist'].'" data-title="'.$val['songName'].'" data-album="'.$val['songName'].'" data-info="" data-image="" data-duration="348">
                    <div class="amazingaudioplayer-source" data-src="http://somthing.info/'.$val['songUrl'].'" data-type="audio/mpeg" />
                </li>';         

    }
      </ul>

when any one first visit my website the i print data with this foreach. if new if new row insert or delete any row or update then reload my website and my foreach retrieve data from database.

please help me how can i do this.

user3098032
  • 49
  • 1
  • 3

3 Answers3

2

In the head you should define as following to refresh the page every 30 mins.

<head>
<meta http-equiv="refresh" content="1800" />
</head>

but this is not the best way to do, you must use ajax. so something like this can be done easily.

setInterval(function(){
  $.ajax({
    url: '/',
    type:"POST",
    data:"", 
    success: function(data){
      //render the dynamic data into html
    }
  });
}, 10000);

check this example to see how you can do the same with ajax. http://www.tutorialspoint.com/php/php_and_ajax.htm

dev1234
  • 5,376
  • 15
  • 56
  • 115
0

you can try something like this using jquery

var seconds = 1800; //add your time interval here

setInterval(function(){
  $.ajax({
      url: 'url of file, which will check the update',
      data: 'pass any data or cache buster in case of proxy'
  });
}, seconds * 1000)
Ram Sharma
  • 8,676
  • 7
  • 43
  • 56
-1

Put a cron on your server to check if new data inserted in the database based on a previously saved db stat.