0

i am using thie jquery code to poll my database:

jQuery(function($){
  setInterval(function(){
    $.get( 'getrows.php', function(newRowCount){
      $('#rowcounter').html( newRowCount );
    });
  },5000); // 5000ms == 5 seconds
});

and display the results here:

<p>There are <span id='rowcounter'>xx</span> rows in the DB.</p>

but i am not sure what to put in the getrows.php file... does there need to be any html tags with an ID of rowcounter or newRowCount?

4

4 に答える 4

1

データベースの行数を取得したら、次のようにします。

<?php echo $rowCount; //Or whatever value you want to show ?>

それで全部です

于 2013-09-27T12:11:37.300 に答える
0

jQueryは、php スクリプトによって返されるデータのタイプをインテリジェントに推測します (php リクエストのスクリプトで ContentType を使用して定義できます)。

単純な php スクリプトは HTML/テキスト データを返すため、PHP スクリプトで番号を「エコー」するだけです。次に、newRowCountJS 値に PHP でエコーされた数値が含まれます。

于 2013-09-27T12:13:53.593 に答える