页面编号未显示

时间:2011-07-05 22:01:07

标签: php jquery jquery-plugins

任何人都知道为什么我的页码没有在分页div中列出?我正在使用tablesorter.pager插件。

<?php
session_start();
require("../inc/dbconfig.php");
require("../inc/global_functions.php");

// find out how many rows are in the table 
$query = "SELECT CONCAT_WS(' ',firstName,lastName) AS name, username, emailAddress, userID FROM manager_users WHERE statusID != 4";
$result = mysqli_query($dbc,$query);

$fileName = basename($_SERVER['PHP_SELF']);
$pageName = "User Accounts";
$userData = $_SESSION['user_data'];
$userID = $userData['userID'];
?>

<script type="text/javascript">
$(document).ready(function() {

 $('a.bt_green').click(function(e) {
    e.preventDefault();
    $('div.right_content').load('forms/addnew/' + $(this).attr('id'));
});

$('#usersPageList').tablesorter().tablesorterPager({container:$('#pagination'),cssPageLinks:'a.pageLink', positionFixed: false});

$('table tr').click(function() {

    checkBox = $(this).children('td').children('input[type=checkbox]');

    if(checkBox.attr('checked'))
        checkBox.removeAttr('checked');
    else
        checkBox.attr('checked', 'checked');

});

$('.ask').jConfirmAction();

$('.ask2').jConfirmAction();    

});
</script>

<h2>User Accounts</h2> 

<table id="usersPageList" class="rounded-corner">

<thead>

    <tr>

        <th scope="col" class="rounded-first"></th>
        <th scope="col" class="rounded">Name</th>
        <th scope="col" class="rounded">Email Address</th>
        <th scope="col" class="rounded">Username</th>
        <th scope="col" class="rounded">Edit</th>
        <th scope="col" class="rounded-last">Delete</th>

    </tr>

</thead>

<tfoot>

    <tr>

        <td colspan="5" class="rounded-foot-left"><em>Displays all of the registered and verified users!</em></td>
        <td class="rounded-foot-right">&nbsp;</td>

    </tr>

</tfoot>

<tbody>

    <?php 
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        echo "<tr>";
            echo "<td><input type=\"checkbox\" name=\"users[]\" value=\"".$row['userID']."\"/></td>";
            echo "<td>".$row['name']."</td>";
            echo "<td>".$row['emailAddress']."</td>";
            echo "<td>".$row['username']."</td>";
            echo "<td><a href=\"#\"><img src=\"images/user_edit.png\" alt=\"\" title=\"\" border=\"0\" /></a></td>";
            echo "<td>";
            if (($row['userID'] !== '10000') && ($row['userID'] !== $userID)){
                echo "<a href=\"#\" class=\"ask\"><img src=\"images/trash.png\" class=\"delete\" alt=\"\" title=\"\" border=\"0\" id=\"".$row['userID']."\" /></a>";
            }
            echo "</td>";
        echo "</tr>";
    }
    ?> 

</tbody>

</table>

<div id="pagination"></div>

<?php
addRemove($fileName,$pageName);
?>
<input type="hidden" name="myhiddenPageToken" id="myhiddenPageToken" value="useraccounts" />

编辑帖子:

<script type="text/javascript">
$(document).ready(function() {

$('a.bt_green').click(function(e) {
    e.preventDefault();
    $('div.right_content').load('forms/addnew/' + $(this).attr('id'));
});

 $('#usersPageList').tablesorter().tablesorterPager({container:$('#pagination'),cssPageLinks:'a.pageLink', positionFixed: false});

$('table tr').click(function() {

    checkBox = $(this).children('td').children('input[type=checkbox]');

    if(checkBox.attr('checked'))
        checkBox.removeAttr('checked');
    else
        checkBox.attr('checked', 'checked');

});

$('.ask').jConfirmAction();

$('.ask2').jConfirmAction();    

});
</script>

<h2>User Accounts</h2> 

<table id="usersPageList" class="rounded-corner">

<thead>

    <tr>

        <th scope="col" class="rounded-first"></th>
        <th scope="col" class="rounded">Name</th>
        <th scope="col" class="rounded">Email Address</th>
        <th scope="col" class="rounded">Username</th>
        <th scope="col" class="rounded">Edit</th>
        <th scope="col" class="rounded-last">Delete</th>

    </tr>

</thead>

<tfoot>

    <tr>

        <td colspan="5" class="rounded-foot-left"><em>Displays all of the registered and verified users!</em></td>
        <td class="rounded-foot-right">&nbsp;</td>

    </tr>

</tfoot>

    <tbody>

        <tr><td><input type="checkbox" name="users[]" value="10000"/></td><td>KOW Management</td><td>kowmanagement@kansasoutlawwrestling.com</td><td>Administrator</td><td><a href="#"><img src="images/user_edit.png" alt="" title="" border="0" /></a></td><td></td></tr><tr><td><input type="checkbox" name="users[]" value="10001"/></td><td>Jeff Davidson</td><td>xtremer360@yahoo.com</td><td>xtremer360</td><td><a href="#"><img src="images/user_edit.png" alt="" title="" border="0" /></a></td><td></td></tr> 

</tbody>

</table>

<div id="pagination"></div>

<a href="" class="bt_green" id="useraccounts.php"><span class="bt_green_lft"></span><strong>Add New User Accounts</strong><span class="bt_green_r"></span></a><a href="" class="bt_blue"><span class="bt_blue_lft"></span><strong>View all User Accounts</strong><span class="bt_blue_r"></span></a><a href="" class="bt_red ask2"><span class="bt_red_lft"></span><strong>Delete User Accounts</strong><span class="bt_red_r"></span></a><input type="hidden" name="myhiddenPageToken" id="myhiddenPageToken" value="useraccounts" />

1 个答案:

答案 0 :(得分:1)

对于要在代码中使用的tablesorterPager插件,我必须自己添加一个分页表单。我将分页div更改为此,从documentation

复制
<div id="pagination">
    <form>
        <img src="../addons/pager/icons/first.png" class="first"/>
        <img src="../addons/pager/icons/prev.png" class="prev"/>
        <input type="text" class="pagedisplay"/>
        <img src="../addons/pager/icons/next.png" class="next"/>
        <img src="../addons/pager/icons/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>

tablesorterPager现在可以正常工作,并修复了tablesorter,如果tablesorterPager找不到表单,它会中断。

我在jquery.tablesorter.pager.js中看不到任何引用来生成表单本身,所以我猜你必须根据表中结果的数量和数字来创建服务器端每页你喜欢的结果。

希望有所帮助