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 8132347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:19:41+00:00 2026-06-06T09:19:41+00:00

Hi i have a table called ‘BookPage’ with column: ‘PageText’ i have set up

  • 0

Hi i have a table called ‘BookPage’ with column: ‘PageText’

i have set up a search on the column ‘PageText’ (see code below). now when the user does a search for a keyword, all the result pages are displayed one below the other.

Is there a way if i could display each pagetext on its individual pages by clicking some sort of ‘Next’ button link they move to the next page.

form.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search</title>
<link href="default.css" rel="stylesheet" type="text/css" media="screen" />
</head>

<body>
<?php

// include MySQL-processing classes

require_once 'mysql.php'; 

try{

// connect to MySQL

$db=new MySQL(array('host'=>'','user'=>'','password'=>'','database'=>''));

$searchterm=$db->escapeString($_GET['searchterm']);

$result=$db->query("SELECT * FROM BookPage WHERE (PageText) like \"%$searchterm%\" ");

if(!$result->countRows()){

echo '<div class="maincontainer"><h2>No results were found. Go back and try a new search.</h2></div>'."n";

}

else{

// display search results

echo '<div class="maincontainer"><h2>Your search criteria
returned '.$result->countRows().' results.</h2>'."n";

while($row=$result->fetchRow()){

echo '<div class="rowcontainer"><p><strong>Book Id:
</strong>'.$row['BookId'].'<p><p><strong>Page Id:
</strong>'.$row['PageId'].'</p><p><strong>Page Text:
</strong>'.$row['PageText'].'</p></div>'."n"; 

}

}

echo '</div>';

}

catch(Exception $e){

echo $e->getMessage();

exit();

}

?>
</body>
</html>

Hi please see modified code below not working could you let me know where i am gone wrong.

modified code

<?php

// include MySQL-processing classes

require_once 'mysql.php'; 

try{

// connect to MySQL

$db=new MySQL(array('host'=>'',''=>'','password'=>'','database'=>''));

    //page
 if (isset($_GET['page'])) {
    $page_no = $_GET['page'];
    $next_pg = $page_no + 1;
} else {
    $page_no = 0;
    $next_pg = 1;
}

    $searchterm=$db->escapeString($_GET['searchterm']); 
    $result=$db->query("SELECT * FROM BookPage WHERE (PageText) like \"%$searchterm%\" ORDER BY BookId ASC LIMIT 0, $page_no");


if(!$result->countRows()){

echo '<div class="maincontainer"><h2>No results were found. Go back and try a new search.</h2></div>'."n";

}

else{

// display search results

echo '<div class="maincontainer"><h2>Your search criteria returned '.$result->countRows().' results.</h2>'."n";

while($row=$result->fetchRow()){

$searchvalue = implode('<span style="color:green;font-weight:800;background-color:yellow;">'.$_GET['searchterm'].'</span>',explode($_GET['searchterm'],$row['PageText'])); 
echo '<div class="rowcontainer"><p><strong>Book Id:
</strong>'.$row['BookId'].'<p><p><strong>Page Id:
</strong>'.$row['PageId'].'</p><p><strong>Page Text:
</strong>'.$searchvalue.'</p></div>'."n";  
}

}

echo '</div>';

}

catch(Exception $e){

echo $e->getMessage();

exit();

}

?>
  • 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-06T09:19:43+00:00Added an answer on June 6, 2026 at 9:19 am

    You can try changing your query to something like:

    if (isset($_GET['page'])) {
        $page_no = $_GET['page'];
        $next_pg = $page_no + 1;
    } else {
        $page_no = 0;
        $next_pg = 1;
    }
    
    $result=$db->query("SELECT * FROM BookPage WHERE (PageText) like \"%$searchterm%\" ORDER BY id ASC LIMIT 1, $page_no");
    

    Then insert a link like:

    <a href="thispage.php?page=<?php echo $next_pg; ?>">Next page</a>
    

    What this will do is get one result at a time and offset the result depending on whichever page you are on. The only important thing to do when doing this is to order the results by something so each query puts the results in the same order. For example, order by ID ASC (per my example).

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

Sidebar

Related Questions

I have table called Buttons. Buttons table i have column button_number . Table contain
I have a table called scheduler_sched which has several columns, including a column called
In my oracle database I have table called PERSON with columns code, surname, forename.
I have table name called Person with following column names P_Id(int), LastName(varchar), FirstName (varchar).
I have a table called Bowzer which has a column called Type . When
I have a table called replies and it has a column named topic_id .
I have a table called user_details this table has got morethan 100k user details
i have table called users , if i want to delete some user (User
Have a table called user_products that contains a record for each product the user
I have a Table called Product and I have the Table StorageHistory . Now,

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.