I am trying to use the jQuery pagination plugin with my PHP/MySQL website — [B] 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
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
[code=html]
<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>”;
}
?>