This script do everything fine counting total records
it display's 1 to 10 records on first page with numbers but
second location where i want it to display Showing results 1 to 10 it shows
17 to 26 second it displays a link to Next but not working.

It takes roughly 20 secs to do a search? Perhaps that should also be looked at.

Try to narrow down your problem.

// begin to show results set
echo " found  $numrows results <p>";
$count = 1 + $s;

Where does $s come from? What is it supposed to mean? (Name your variables properly).

// now you can display the results returned
 while ($row= mysql_fetch_array($result)) {

 $title = $row["sname"];
 $url = $row["url"];
 $message = $row["massage"];
//&nbsp;<a href=\"$row['url']\">"$row['sname']</a><br />

 echo "$count.)&nbsp";
 echo "<b><a href=\"$url\" target=\"_blank\">$title</a></b>";
 echo "<br>";
 echo "$message<br><hr height=12 color=lightblue><br>";


$currPage = (($s/$limit) + 1);

//break before paging
 echo "<br />";

 // next we need to do the links to other results
 if ($s>=1) { // bypass PREV link if s is 0
 print "&nbsp;<a href='{$_SERVER['PHP_SELF']}?s=$prevs&q=$var'> <<<
 Prev 10</a>&nbsp&nbsp;";

// calculate number of pages needing links
//  $s=intval($numrows/$limit);

// $s now contains int of pages needed unless there is a remainder from

 if ($numrows%$limit) {
 // has remainder so add one page

What is $s set to here when there's extra pages to display?

// check to see if last page
 if (!((($s+$limit)/$limit)==$s) && $s!=1) {

That's just too complicated to read. The first part seems redundant since you're calculating $s anyway, why re-do it?

// are there extra pages to display?
if ($s > 1) {
  echo "show extra pages";

 // not last page so give NEXT link  $PHP_SELF &gt;&gt;

 echo "&nbsp;<a href='{$_SERVER['PHP_SELF']}?s=$news&q=$var'>Next 10 >>>


$a = $s+$limit;
 if ($a > $numrows) { $a = $numrows; }
$b = $s+1;
 echo "<p>Showing results $b to $a of $numrows</p>";
include ('');

I shall highly appreciate if anyone shall have a look at it
and let me know where i am wrong.

Thank you.

Postgresql & php tutorials

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to