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 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统