I've been following several tutorials in order to build a simple search engine for my website. But I can't seem to be able to do pagination I.E show results by pages (10 per page).

I'll list the code I have thus far and hopefully if there's someone well versed with this stuff can fill in/advise me on how to add the pagination.

Here's the code:

  $var = @$_GET['q'] ;
  $search = trim($var); //trim whitespace 
  $limit = 10;


 $query = "SELECT * FROM table WHERE value LIKE \"%$search%\""; 

  if ($numrows > 0) //do following if there are results to show
  // if s hasn't been passed to script, use 0
  if (empty($s)) {
  $count = 1 + $s ;

// get results
  $query .= " limit $s,$limit";
  $result = mysql_query($query) or die("Couldn't execute query");
  while ($row = mysql_fetch_array($result)) { 
  $title = $row["title"];
  echo $title;

$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
  echo "About $b to $a of $numrows results";

This is for part of a coursework and I have a deadline to meet so it would be great if someone can offer some help soon!

Edited by asif49: n/a

6 Years
Discussion Span
Last Post by codewalkz
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.