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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:51:59+00:00 2026-06-06T13:51:59+00:00

I am new to the whole php, sql, jquery. I am trying to paginate

  • 0

I am new to the whole php, sql, jquery. I am trying to paginate a sql gallery. I keep getting an error when using the sql LIMIT clause.

It either spits all the images out on one page but gives non functioning page number buttons OR only shows the selected number of items but doesnt create extra pages for the rest of the queries results.

I have searched for a solution and found that there was a problem with using variables after the LIMIT function. Can anyone either show me a better way to implement this or give me a solution to my problem.

    $items = 8; 

if(isset($_GET['page']) and is_numeric($_GET['page']) and $page = $_GET['page'])
             $limit = " LIMIT ".(($page-1)*$items).",$items";
          else
             $limit = " LIMIT $items";


if(empty($clothing) && empty($price) && empty($uploaded)) {    
$query = "SELECT path, description, filename  FROM category $limit";
$result = mysql_query($query) or die(mysql_error());

I have also tried this below which gives an error.

    $per_page = 8; 

if(isset($_GET['page']))
{
$page=$_GET['page'];
}
$start = ($page-1)*$per_page; 

if(empty($clothing) && empty($price) && empty($uploaded)) {
$query = "SELECT path, description, filename  FROM category LIMIT $start, $per_page ";
$result = mysql_query($query) or die(mysql_error());

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘-8, 8’ at line 1.

To shed more light the ‘if’ is to filter the queries results. This is just the first of many sql queries.

Thanks

  • 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-06T13:52:01+00:00Added an answer on June 6, 2026 at 1:52 pm

    Offset value for LIMIT cannot be negative

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

Sidebar

Related Questions

I'm trying to feed data from SQL database to FLEX, using php script in
im new in php sql and stuff, and I've been trying to think in
I am implementing chat using PHP, SQL, JavaScript. I am checking for new messages
I am new to the whole MVP thing and slowly getting my head around
I'm new to this whole Joomla thing, and I'm trying to get an swf
New to whole this jQuery (and javascript altogether, heh) and so far it's been
I am using jQuery to load the search results from a php class when
Using PHP and MySQL I'm trying to get all the distinct values out the
im very new to this and have a very basic knowledge php and SQL
Ok, so im new in php and sql, and I have this form that

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.