dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: jQuery Pagination and MySQL $limit, $offset

  1. #1
    Join Date
    Jan 2005
    Posts
    119

    jQuery Pagination and MySQL $limit, $offset

    I am trying to use the jQuery pagination plugin with my PHP/MySQL website -- It appears I have to either use Ajax or use PHP to write the jQuery pagintion header so I can control the $offset and $limit, in order to control the pagination --

    What is the best way to combine javascript, PHP and MySQL so that they can communicate with eachother? Here is my PHP page and SQL

    HTML Code:
    <script type="text/javascript" src="include/jquery-latest.js"></script>
    <script type="text/javascript" src="include/tablesorter/addons/pagination/jquery.pagination.js"></script>
    <link rel="stylesheet" href="include/tablesorter/addons/pagination/pagination.css" type="text/css" media="print, projection, screen" />
    <script type="text/javascript">
                
    		function pageselectCallback(page_id, jq){
    					$('#Searchresult').text("Showing search results "+((page_id*10)+1)+"-"+((page_id*10)+10));
                    }
    		
            $(document).ready(function(){
    			// Create pagination element
                $("#Pagination").pagination(300, {
    				num_edge_entries: 2,
    				num_display_entries: 8,
                    callback: pageselectCallback
                });
            });
                
            </script>
    
    <div id="Pagination" class="pagination"></div>
    
    		<br style="clear:both;" />
    		<div id="Searchresult">
    			Showing search results 1-10 ...
    		</div>
    
    
    <?php
    
    	$limit = 10;
    	$offset = 0;
    
    	dbConnect();
    	$sql = "SELECT * FROM emt_company LIMIT $offset, $limit";
    	$result = mysql_query($sql) or die(mysql_error());
    	$num = mysql_num_rows($result);
    	
    
    	while($row = mysql_fetch_assoc($result)){
    		
    		$name = $row['name'];
    		echo "$name<br>";
    	
    	}
    
    
    ?>
    Last edited by ripcurlksm; 01-03-2009 at 06:51 PM.

  2. #2
    Join Date
    Jan 2005
    Posts
    119
    bump

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles