Jump to content

Pagination


Xtremer360

Recommended Posts

The problem here is my pagination. It works for the most part. The only part that does NOT work is that when I go to a page OTHER THAN the first page it WILL NOT allow me to click on the edit link and go to the edit matchtype form. It allows me to on the first page of list but not for any after that.

 

<?php

error_reporting(E_ALL);

// Include the database page
include ('../inc/dbconfig.php');

$query = "SELECT 
    CONCAT_WS(' ', handlers.firstName, handlers.lastName) AS name, 
    DATE_FORMAT(matchTypes.dateCreated, '%M %d, %Y') AS dateCreated, 
    matchTypes.ID, 
    matchTypes.matchType 
FROM 
    matchTypes
    INNER JOIN handlers 
        ON matchTypes.creatorID = handlers.ID
WHERE 
    matchTypes.enabled = '0'
ORDER BY 
    matchTypes.matchType";
$result = mysqli_query ( $dbc, $query ); // Run The Query
$rows = mysqli_num_rows($result);

$itemsPerPage = 10;
$pages = ceil( $rows / $itemsPerPage );

?>

<script>
$(document).ready(function() {
    $('a', $('div#addform')).click(function() {
        $('#innerContent').load('forms/' + $(this).attr('id') + '.php?case=addnew');
    });

// Add the table sorter and table paginator plugins
$('#matchTypesPageList').tablesorter() 
                            .tablesorterPager({
                    			container: $( '#matchTypesPageList .paginate' ),
                    			cssPageLinks: 'a.pageLink'
                    		});
    $('.edit').click(function(){
        var matchTypeID = $(this).attr('rel'); 
        $('#innerContent').load('forms/matchtype.php?id=' + matchTypeID + '&case=edit');
    });
    $('.delete').click(function(){
        var matchTypeID = $(this).attr('rel'); 
        var dataString = 'matchTypeID=' + matchTypeID + '&deleteMatchType=True'; 
        $.ajax({ 
            type: "POST", 
            url: "processes/matchtype.php", 
            data: dataString, 
        });
        var table = $(this).closest("table");
        if (table.find("tr").length == 3) {
            table.remove();
        } else {
            $(this).closest("tr").remove();
        }  
    });                                              
});
</script>

<!-- Title -->
<div id="title" class="b2">
<h2>Match Types</h2>
<!-- TitleActions -->
<div id="titleActions">
	<!-- ListSearch -->
	<div class="listSearch actionBlock">
		<div class="search">
			<label for="search">Recherche</label>
			<input type="text" name="search" id="search" class="text" />
		</div>
		<div class="submit">
			<button type="submit" id="search-button" class="button"><strong><img src="img/icons/search_48.png" alt="comments" class="icon "/></strong></button>
		</div>
	</div>
	<!-- /ListSearch -->
	<!-- newPost -->
	<div id="addform" class="newPost actionBlock">
		<a href="#" id="matchtype" class="button"><strong>Add New Match Type<img src="img/icons/add_48.png" alt="new post" class="icon "/></strong></a>
	</div>
	<!-- /newPost -->
</div>
<!-- /TitleActions -->
</div>
<!-- Title -->
<!-- Inner Content -->
<div id="innerContent">
    <!-- ListHeader -->
<div id="listHeader">
	<p class="listInfos">
		You have <?php echo $rows; ?> match types.
	</p>
</div>
<!-- /ListHeader -->
    <!-- ListTable -->
    <?php if ($rows > 0) { ?>
    	<table cellspacing="0" class="listTable" id="matchTypesPageList">
    		<!-- Thead -->
    		<thead>
    			<tr>
    				<th class="first"><div><a href="#" title="Match Type Name">Match Type Name</a></div></th>
    				<th><a href="#" title="Creator">Creator</a></th>
    				<th><a href="#" title="Date Created">Date Created</a></th>
                    <th class="last">Edit/Delete</th>
    			</tr>
    		</thead>
    		<!-- /Thead -->
    		<!-- Tfoot -->
    		<tfoot>
    			<tr>
    				<td colspan="4">
    					<div class="inner">
    						<div class="paginate">
                                <?php
							if( $pages > 1 ) {
								for( $i = 1; $i <= $pages; $i++ ) {
									echo '<span style="padding-left: 5px; padding-right: 5px;"><a class="pageLink" href="#">' . $i . '</a></span>';
								}
							}
  								?>
    						</div>
    					</div>
    				</td>
    			</tr>
    		</tfoot>
    		<!-- /Tfoot -->
    		<!-- Tbody -->
            <tbody>
    		<?php 
        while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) {
              echo '
              <tr>
    			  <td>' . $row['matchType'] . '</td>
    			  <td>' . $row['name'] . '</td>
    			  <td>' . $row['dateCreated'] . '</td>
                  <td style="text-align:center;"><img src="img/notepad.png" class="edit" rel="' . $row['ID'] . '"/><img src="img/Delete-icon.png" class="delete" rel="' . $row['ID'] . '"/></td>
		  </tr>';
            }
            ?>
    		</tbody>
    		<!-- /Tbody -->
    	</table>
        <?php
        }
        ?>
<!-- /ListTable -->
</div>
<!-- /Inner Content -->

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.