title: Get current playback time for multiple videos
body: <p>I need to get the current playback time for multiple videos from database. </p>
  
  <p>I want to save the playback video time in the database, so I can later set the correct position for the user when he comes in.</p>
  
  <p>I am using <code>setInterval</code> to fire ajax every 4 seconds. Any help please?</p>
  
  <p>Code</p>
  
  <pre><code>&lt;?php
  
  $tl="channel";
  $ooa="playing";
  $played="played";
  
  $timeline = mysqli_query($con, "SELECT * FROM plays WHERE streamers_type ='$tl' AND played !='$played' GROUP BY streamers_id ORDER BY id ASC") or die ();
  
  while($row = mysqli_fetch_array($timeline)) {
      $id = $row['id'];
      $file1 = $row['file1'];
      $video_name = $row['video_name'];
      $video_type = $row['video_type'];
      $about_video = $row['about_video'];
      $streamers_type = $row['streamers_type'];
      $streamers_id = $row['streamers_id'];
      $time_start = $row['time_start'];
      $time_stop = $row['time_stop'];
      $date = $row['date'];
      $streamers_name = $row['streamers_name'];
      $views = $row['views'];
      $played = $row['played'];
  
              ?&gt;  
      &lt;li class="col-lg-4 col-sm-5 col-xs-12 spinal"&gt;
      &lt;b style="border:1px solid; color:red; margin-left:3px!important;"&gt;&lt;?php echo $streamers_name ?&gt;&lt;/b&gt;
      &lt;span class="pull-right"&gt;&lt;span id = "fhkj"&gt;&lt;?php echo $views?&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&lt;i class="fa fa-eye"&gt;&lt;/i&gt;&lt;/span&gt;
          &lt;a class="fg" title="&lt;?php echo $video_name ?&gt;"&gt;
          &lt;button data-toggle="modal" data-target="#modal-1" data-backdrop="static" data-keyboard="false"  class="fire" id="&lt;?php echo $id ?&gt;"&gt;
  
          &lt;video class="uopi " id="&lt;?php echo $video_name ?&gt;" style="height:180px; width:100%!important;" autoplay muted onended="run();"&gt;&lt;source src="plays/&lt;?php echo $file1 ?&gt;" type="&lt;?php echo $video_type ?&gt;"&gt;&lt;/video&gt;
  
          &lt;h2 style="background-color:#fff;color:orange; line-height:30px; font-size:1.3em;"&gt;&lt;?php echo $video_name ?&gt;&lt;/h2&gt;
              &lt;span class="glyphicon glyphicon-play-circle"&gt;&lt;/span&gt;&lt;/button&gt;
  
          &lt;/a&gt;
      &lt;/li&gt;
            }
       ?&gt;
  
  
  
  
             &lt;script type='text/javascript'&gt; //function to update time    
           var vid = $('.uopi').attr('id');
     var ok = vid.currentTime;
        $(document).ready(function() {
       setInterval(function () {
            $.ajax({
            type : 'POST',
             url : 'updatetime.php', 
            data :  {ok: ok}, .
            success : function(r)
             {
            alert('Yay'); //would be commented out later dont really need any success just save
  
             }
      });
  
       }, 4000);
  })   
  &lt;/script&gt;
  </code></pre>