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

  • Home
  • SEARCH
  • 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 6177933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:21:47+00:00 2026-05-24T00:21:47+00:00

I am having a pagination for my script that paginates the results based on

  • 0

I am having a pagination for my script that paginates the results based on a search term, but I came up with a small problem.

When the search term is an english string like laptop it works great.

When the word is not english, (greek) even it outputs the correct number of matches found, it shows me only the first page with the 10 results. When I click on page 2 or next, it shows again the correct number of matches but it does not display any of them. If I click from page 2 to page 1, then it shows me again the results of the first page.
So, generally only the first (landing) page works.

I have tested the code before editing to GET a term with a non latin string and did the same ‘wrong’ thing.
This is the url to the tutorial http://papermashup.com/easy-php-pagination/

Thank you for your time and replies.

  • 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-05-24T00:21:47+00:00Added an answer on May 24, 2026 at 12:21 am

    First of all, you can catch an SQL injection attack with none-escaped input. Then, I think that your search term may break SQL query. Try using mysql_real_escape_string:

    $all = mysql_real_escape_string(implode(" +",$words)); 
    

    The page may only be numerical and then it’s safe to do:

    $page = (int) $_GET['page'];
    

    without escaping string.

    Then and most important: query for counting and query for data MUST have same JOIns and WHERE parameters. If you search for matches in one table you can get 100 rows. Then you’re trying to JOIN it with another table, where only 10 rows found. You’ll get only 10 rows for data and 100 rows for pages.

    $query = "SELECT COUNT(some_id_column) as num FROM products JOIN shops 
    ON products.shopid = shops.id WHERE MATCH (name) AGAINST ('+" . $all . "' IN BOOLEAN MODE)";
    

    And you don’t need to include AND products.shopid = shops.id to your WHERE clause if you already have it in HAVING clause.

    Then, the result of your first query is not PAGES count, it’s ROWS count. If you want to show 10 rows on a page, then your total pages count will be ceiling($total_pages / 10).

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

Sidebar

Related Questions

I'm having a small problem with the pagination message that displaytag is outputting for
This is my pagination script which extracts info for my TV guide project that
I've been having some issues with a pagination widget that I wrote in jQuery.
I am having trouble with modifying a php application to have pagination. My error
Having a problem getting a TreeView control to display node images. The code below
I'm placing an entire pagination script into a function so I can use it
I'm having some problems with creating pagination with a HABTM relationship. First, the tables
I have a working pagination script, it displays the data with few issues. However,
Having a problem while passing messages using content scripts in Google chrome extension dev
Having been a PHP developer on LAMP servers for quite a while, is there

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.