Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 要计算表中的行总数吗_Php_Html_Jquery - Fatal编程技术网

Php 要计算表中的行总数吗

Php 要计算表中的行总数吗,php,html,jquery,Php,Html,Jquery,我正在进行敲除绑定,以便将值插入表中。 如果表中的行数为0,则我必须显示一条警报消息。 但为此,我需要计算显示数据的行数 我的观点代码如下: <table class="table table-hover table-bordered datagrid" style="width: 355px;" id="remodellingTable"> <thead> <tr> <th>Firs

我正在进行敲除绑定,以便将值插入表中。 如果表中的行数为0,则我必须显示一条警报消息。 但为此,我需要计算显示数据的行数

我的观点代码如下:

    <table class="table table-hover table-bordered datagrid" style="width: 355px;" id="remodellingTable">
       <thead>
         <tr>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Address</th>
            <th>City</th>
            <th>State</th>
         </tr>
       </thead>
       <tbody data-bind="foreach:items">
          <tr>
             <td data-bind="text:fname" id="tdfname"></td>
             <td data-bind="text:lname"></td>
             <td data-bind="text:addr"></td>
             <td data-bind="text:city"></td>
             <td data-bind="text:state"></td>
          </tr>
       </tbody>
    </table>
<button type="button" class="btn" id="nexttarget"> Next <i class="icon-arrow-right"></i></button>

您忘记使用$调用jQuery了:

如果不调用jQuery,您只是在计算字符串“RemoModelTable>tbody>tr”的长度,这显然是不相关的

var rowcount = $('#remodellingTable > tbody > tr').length;

而不是var rowcount='remodelingtable>tbody>tr'.length

那么问题出在哪里呢?你是不是想改造$'。。。您缺少$I think var rowcount=$'RemoldlingTable>tbody>tr:has[data bind]';workNice是否应该捕获我错过的@ExplosionPills,它将rowcount的值显示为“30”
var rowcount = $('#remodellingTable > tbody > tr').length;
var rowcount = $('#remodellingTable > tbody > tr').length;