0

I want to echo a form every 30 minutes each day for 18 repetition each day and this repetition will appear each 30 minutes and when the form appear the user will check the checkbox and submit the form and when he submits the form the form disappears and this will be do it 18 repetition per day.

I tried this code but it not show me any thing it still running without any output:

$dailydatetime=date('Y-m-d H:i:s');
$echo_time = time();
$interval = 1*60;
  while(true){
    if ($echo_time + $interval >= time()){
      echo "<form method='Post' action=''>";
      echo"<input type='checkbox' name='check' value=''>"  ;
      echo"<input type='submit' name='add' value='Check'>";  
      echo"</form>";  
      $echo_time = time(); 
    }

  }
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
mhmd
  • 254
  • 2
  • 3
  • 14
  • Where is the jquery part? – ka_lin Sep 20 '16 at 07:11
  • Where is the Ajax and not the cleaning Kind. – ArtisticPhoenix Sep 20 '16 at 07:12
  • @ka_lin i didn't use any jquery but i add jquery maybe i need it in my code but i don't know – mhmd Sep 20 '16 at 07:12
  • PHP should not be used for waiting because there are a limited amount of connections to a server and this loop will consume 1 CPU thread for a single user, use JavaScript timer events. – Xorifelse Sep 20 '16 at 07:14
  • You need some javascript because php is compiled server side so displaying the form every 30 min means that is a front-end solution: use native js setInterval(), ajax via jquery and get back if you have problems. – ka_lin Sep 20 '16 at 07:15
  • @ka_lin can you please aid me with this because i don't have a big experience in javascript – mhmd Sep 20 '16 at 07:21
  • http://stackoverflow.com/questions/2579762/setinterval-by-the-minute-on-the-minute and http://stackoverflow.com/questions/10575928/ajax-response-inside-a-divshould help – ka_lin Sep 20 '16 at 07:26

0 Answers0