2017-02-20 1 views
-1

전 테이블 JSon을 사용하고 있습니다. 하지만 PHP에서 Json으로 인코딩했습니다. 그래서 테이블에서 pin.php 파일을 호출합니다. 예를 들어 내 HTML 테이블 :자동 새로 고침 표 JSON

HTML :

<table 
    data-url="../../tables/pin.php" 
    data-row-style="rowStyle" 
    data-toggle="table" 
    data-show-refresh="true" 
    data-show-toggle="true" 
    data-show-columns="true" 
    data-search="true" 
    data-select-item-name="toolbar1" 
    data-pagination="true" 
    data-sort-name="name" 
    data-sort-order="desc"> 
    <thead> 
     <tr> 
      <th data-field="id_pin" data-sortable="true" data-align="center">ID PIN</th> 
      <th data-field="no_meja" data-sortable="true" data-align="center">Nomor Meja</th> 
      <th data-field="status" data-sortable="true" data-align="center">Status</th> 
      <th data-field="action" data-sortable="true" data-align="center">Input Pemesanan</th> 
     </tr> 
    </thead> 
     <tr> 
     </tr> 
</table> 

스크립트 테이블 :

<script> 
    $(function() { 
     $('#hover, #striped, #condensed').click(function() { 
      var classes = 'table'; 

      if ($('#hover').prop('checked')) { 
      classes += ' table-hover'; 
      } 
      if ($('#condensed').prop('checked')) { 
      classes += ' table-condensed'; 
      } 
     $('#table-style').bootstrapTable('destroy') 
      .bootstrapTable({ 
      classes: classes, 
      striped: $('#striped').prop('checked') 
      }); 
     }); 
}); 

function rowStyle(row, index) { 
    var classes = ['info', 'info', 'info', 'info', 'info']; 

    if (index % 2 === 0 && index/2 < classes.length) { 
     return { 
      classes: classes[index/2] 
     }; 
    } 
return {}; 
} 
</script> 

질문 :이 테이블은 자동 새로 고침입니다합니다. 도와주세요.

+0

내가 질문에서 PHP를 제거했습니다, 그것은 완전히 무관의로. 그러나 유지 보수가되지 않고 안전하지 않으며 비추천 된 데이터베이스 API를 사용하고 있음을 지적해야합니다. 이 코드를 라이브로 작성하면 약 30 초 내에 전체 데이터베이스를 쉽게 덤프 할 수 있습니다. PDO와 같은 대안은 10 년 이상 이용 가능합니다. 그것을 써. http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – miken32

답변

0

부트 스트랩 테이블을 사용하고있는 것 같습니다. the documentation에 따르면, 테이블을 새로 고칠 수 있습니다, 그래서 그냥 set a timer 정기적으로 그것을 할 :

(function(){ 
    function refreshTable() {$('#table-style').bootstrapTable('refresh', {silent: true});} 
    setInterval(refreshTable, 5000); 
})() 
+0

작업을 참조하십시오. 고맙습니다. –