Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7817513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:14:52+00:00 2026-06-02T06:14:52+00:00

The following script is showing only first page and link to next page is

  • 0

The following script is showing only first page and link to next page is there but is not leading anywhere. Can someone help me?

$var = @$_GET['q'] ;
$trimmed = trim($var);
$limit = 10;

if ($trimmed == "")
{
    echo "<p>What are you looking for?...</p>";
    exit;
}

if (!isset($var)) 
{   
    echo "<p>We dont seem to have a search parameter!</p>";
    exit;
}

mysql_connect('xxx', 'yyy', 'zzz');
mysql_select_db('yyy') or die('Unable to select database');
$query = "select * from table  where NAME like '%$trimmed%' order by NAME";
$numresults = mysql_query($query);
$numrows = mysql_num_rows($numresults);

if ($numrows == 0)
{
    echo "<h4>Results</h4>";
    echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>";
    echo "<p><a href=\"http://www.google.com/search?q="
    . $trimmed . "\" target=\"_blank\" title=\"Look up
    " . $trimmed . " on Google\">Click here</a> to try the search on google</p>";
}

if (empty($s)) 
{
    $s = 0;
}

$query .= " limit $s,$limit";
$result = mysql_query($query) or die("Couldn't execute query");
echo "<p>You searched for: &quot;" . $var . "&quot;</p>";
echo "Results";
$count = 1 + $s;

while ($row= mysql_fetch_array($result)) 
{
    $title = $row["NAME"];
    echo "$count.-&nbsp;$title" ;
    $count++ ;
}

$currPage = (($s/$limit) + 1);
echo "<br />";

if ($s >= 1) 
{ 
    // bypass PREV link if s is 0
    $prevs = ($s - $limit);
    print "&nbsp;<a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt;
    Prev 10</a>&nbsp;";
}

$pages = intval($numrows/$limit);

if ($numrows % $limit) 
{
    $pages++;
}  

if (!((($s+$limit)/$limit) == $pages) && $pages != 1) 
{
    $news = $s + $limit;
    print "<a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 &gt;&gt;</a>";
} 

$a = $s + ($limit);

if ($a > $numrows) 
{ 
    $a = $numrows; 
}

$b = $s + 1;
echo "<p>Showing results $b to $a of $numrows</p>";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:14:53+00:00Added an answer on June 2, 2026 at 6:14 am

    In your code, $s gets reset every time the page is reloaded or the next page link is clicked. You should have $s = $_REQUEST['s'] at the beginning of your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following script will update the database, but it won't display the correct page
I have the following script which first shows only the first para of the
The script I am using 'gets' a html page and parses is showing only
the following perl script (Showing down) print the following XML file but the XML
The following script works to open Firefox's location/awesome bar from anywhere using control-l ,
I create the following XML file, by perl script (Showing down) , using XML::LibXML:
I have a problem when I create page with the script showing document.write(Text); text
i have the following script. everything works fine in ff, safari. But in IE
I have the following script inside a HTML page: <script> function Test(){ alert(i got
I am trying to modify the following script to show/hide the Tip only when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.