dsfdsf21321 2011-06-01 12:02
浏览 66
已采纳

jquery tablesorter没有排序

hello i am stuck with jquery tablesorter: http://tablesorter.com/docs/index.html#Examples

and would be grateful if some jquery guru could check my code to see where i am going wrong. instead of displaying 10 records per page it is displaying all records and also when i try to sort it does nothing. in addition to that, there are no zebra stripes appearing. all libraies are loaded and there are no errors in firebug. many thanks for your help.

<?php
$q=$_GET["q"];

$con = mysql_connect('localhost', 'root', '');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("sample", $con);

$sql="SELECT * FROM logger_log WHERE idusr_log = '".$q."' order by datein_log desc";

$result = mysql_query($sql);

echo "<table id=\"userlog\" class=\"tablesorter\">
<thead>
<tr>
<th align=\"left\">Ip Address</th>
<th align=\"left\">Date In</th>
<th align=\"left\">Date Out</th>
</tr>
</thead>";

while($row = mysql_fetch_array($result))
  {
  echo "<tbody>";
  echo "<tr>";
  echo "<td>" . $row['ip_log'] . "</td>";
  echo "<td>" . date('d/m/Y H:i:s',strtotime($row['datein_log'])) . "</td>";
  echo "<td>" . date('d/m/Y H:i:s',strtotime($row['dateout_log'])) . "</td>";
  echo "</tr>";
  echo"</tbody>";
  }
echo "</table>";


mysql_close($con);
?>
<div id="pager" class="pager">
    <form>
        <img src="css/blue/first.png" class="first"/>
        <img src="css/blue/prev.png" class="prev"/>
        <input type="text" class="pagedisplay"/>
        <img src="css/blue/next.png" class="next"/>
        <img src="css/blue/last.png" class="last"/>
        <select class="pagesize">
            <option selected="selected"  value="10">10</option>
            <option value="20">20</option>
            <option value="30">30</option>
            <option  value="40">40</option>
        </select>
    </form>
</div>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.pager.js"></script>
<link href="css/blue/style.css" rel="stylesheet" type="text/css" />
        <script>
        $(document).ready(function()     
        {   
            $("#userlog")
            .tablesorter({widthFixed: true, widgets: ['zebra']})     
            .tablesorterPager({container: $("#pager")});     

        } );
        </script>
  • 写回答

2条回答 默认 最新

  • dongxun3424 2011-06-01 12:09
    关注

    You need to remove the <tbody> fom your results loop and place it around your while loop.

    echo "<tbody>";
      while($row = mysql_fetch_array($result)) {  
        echo "<tr>";
          echo "<td>" . $row['ip_log'] . "</td>";
          echo "<td>" . date('d/m/Y H:i:s',strtotime($row['datein_log'])) . "</td>";
          echo "<td>" . date('d/m/Y H:i:s',strtotime($row['dateout_log'])) . "</td>";
        echo "</tr>";  
      }
      echo"</tbody>";
    echo "</table>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化