tags:

views:

74

answers:

2

Hello, I am trying to fix this pagination script. It seems when I click on the pagination links [1][2][3][4]or[5] , it doesn't work. It just shows the first page and when clicking on the next numbers nothing happens. I hoping someone can see something in the script that I can not see.

The main page looks like this (pagination.php):

<?php
include_once('generate_pagination.php');
?>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"&gt;&lt;/script&gt;
<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() ?>


</ul>


<br />
<br />

<a href="#" class="category" id="marketing">Marketing</a>

<a href="#" class="category" id="automotive">Automotive</a>

<a href="#" class="category" id="sports">Sports</a>

Then, generate_pagination.php:

<?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>';
  }
}

$ids=$_GET['ids'];
generate_pagination("SELECT COUNT(*) FROM explore WHERE category='$ids'");

?>

So, if anyone sees where the problem is occurring and can help rid of the problem, that would be great, Thank you.

+1  A: 

As a matter of fact, programming science has more powerful technique to find and eliminate errors in the code, instead of "looking in the script to see something".

This technique called "debugging".

IBM has nice introduction article in this art, here you are: http://www.ibm.com/developerworks/library/os-debug/

To debug an AJAX application is quite hard, but it's still possible. Divide your task into smaller ones and debug them separately. Feel free to ask for more details.

Col. Shrapnel
+1  A: 

One problem I see is that you're calling generate_pagination without the $sql parameter.

But I think we'd need to see what Javascript is being used in order to understand exactly what is wrong with the code. Where are the events defined for when you click on a page number?

DisgruntledGoat