Hello, I am still trying to update my sql query more dynamically but finding it difficult since im new to both PHP and jquery.
I have one main page (pagination.php) that looks like this:
<?php
function generate_pagination($sql) {
include_once('config.php');
$per_page = 3;
//Calculating no of pages
$result = mysql_query($sql);
$count = mysql_fetch_row($result);
$pages = ceil($count[0]/$per_page);
//Pagination Numbers
for($i=1; $i<=$pages; $i++)
{
echo '<li class="page_numbers" id="'.$i.'">'.$i.'</li>';
}
}
?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery_pagination.js"></script>
<div id="loading" ></div>
<div id="content" data-page="1"></div>
<ul id="pagination">
<?php generate_pagination("SELECT COUNT(*) FROM explore WHERE category='marketing'"); ?>
<a href="#" class="category" id="marketing">Marketing</a>
<a href="#" class="category" id="automotive">Automotive</a>
<a href="#" class="category" id="sports">Sports</a>
As you can see the top part of the script is calculating the number of pages for the pagination and then displays the numbers based on how many results in the database from this query:
<?php generate_pagination("SELECT COUNT(*) FROM explore WHERE category='marketing'");
This is were I'm having difficulty, I want to make the category part of the above query more dynamic. So, when the user clicks any of the three links, I want the id of the link clicked to be placed in the category part of the query using jquery.
Here is my jquery code:
$("#pagination a").click(function () {
Display_Load();
var this_id = $(this).attr('id');
var pageNum = $('#content').attr('data-page');
$("#content").load("filter_marketing.php?page=" + pageNum +'&id='+this_id, Hide_Load());
});
I hope that made sense, and if anyone can assist me on this that would be great.