LIMIT the mysql record using Pagination Limit

I need to display maximum 20 pages and each page has 10 posts that means I need to limit 200 records in MySQL query am using this code.

$sql = "SELECT title FROM $tbl_name ORDER BY ID DESC LIMIT 200 $start, $limit";

start and limit is using for pagination page limit, but it doesn't work.

-------------Problems Reply------------

You cannot have LIMIT 200, and then also limit 10 in these as well.

$sql = "SELECT title FROM $tbl_name ORDER BY ID DESC LIMIT $start, $limit";

This will limit it to whatever $limit is, and start at whatever index $start is.

If you really need to limit it to 200 rows, and then have pagination within these, you should either do it in PHP, or create a MySQL View.

If you need only 10 records per request you should:

$sql = "SELECT title FROM $tbl_name ORDER BY ID DESC LIMIT $start, 10";

Category:php Views:3 Time:2018-04-14
Tags: php mysql

Related post

  • How can I limit the cpu space used by Store Broker 2013-02-04

    How can I limit the CPU space used by Store Broker? --------------Solutions------------- Hi DDKinney, WSHost.exe, RuntimeBroker.exe are the files that are required for Windows store and Modern apps. So, they consume more CPU. 1. How many modern apps

  • Configure Web Deploy Publishing - Unable to establish a connection to the MySQL database using the supplied connection string 2014-09-16

    I’m am trying to use Microsoft WebMatrix version 3 to create and publish a WordPress site to an IIS 8.0 server. I have created the WordPress site from the WebMatrix App Gallery and as part of this process MySQL has been installed locally on my PC. I

  • How to limit the database records that are displayed in webpage using JSP? 2012-03-06

    I have to retrieve the more than 100 records from the Database table using JSP. So, i want to control those database records into 10 records per page and each page will have the next and previous buttons contains link for these Pagination. So, is the

  • Get the Width of Div and LIMIT the mySQL query according to no of elements? 2012-02-05

    I needed to display number of images in <li><img class='1'><img class='1'><img class='1'></li> <li><img class='1'><img class='1'><img class='1'></li> but as my div is auto increasing accordi

  • mysql cursor use dynamic limit 2012-03-01

    is there a way to use dynamic limit in the cursor? DECLARE cursor_friends CURSOR FOR SELECT `name` FROM iFriends LIMIT iLimit, 50; I have read on some forums that mysql cursors don't support dynamic limit in cursors. wondering if there is some altern

  • Limit the encrypted result using AES 2011-02-10

    I need to encrypt a text (16 chars), preferably using AES, and I need limit the length of the result encrypted text (14 or 16 characteres). The encrypted has to be only chars and numbers (not '=', '?', ...) Is it possible? I'll need to get back the o

  • mongodb - insert but limit the total records? 2012-09-08

    A while back when I was researching MongoDB I came across an article where they explained how to be able to insert records but only keep 10 (for example), so once it hit 10 records then it would delete the oldest record and insert the newest. This wa

  • Update duplicate MySQL record using PHP 2011-08-30

    I need to update the duplicate records in database using PHP. For example: I have three identical record micheal in the database. I'm in urgent need to update the two micheal records into micheal 1 and micheal 2,but left one micheal as is. Can any on

  • MySQL Dump Limit? MySQL overall database size limit? 2011-08-05

    Client just had ~1000 rows of data (most recent, of course), just go missing in one of their tables. Doing some forensics, I found that the "last_updated_date" in all of their other rows of said table was also set to roughly the same time as the dele

  • Update Mysql record using gridview with checkbox column 2012-02-24

    I have a table in mysql databse with a boolean column (or tinyint(1)). In my web application i used a gridview to view the data from that table and I used a checkbox field for the boolean column. Everything's ok till here. When I try to update a reco

  • Finding the MX Record using C#? 2010-11-26

    How can I find the MX record for a mail server in C#? Thanks --------------Solutions------------- You can use the answer of Robert and RPK to get the MX record of a given domain. But you'll need a DNS server to do the job. If you want to detect the D

  • adding the number of referrals and referral id's into the MySQL DB using PHP 2011-03-17

    I have setup a referral system, whereby a user enters their email address and can then refer a friend. The friend is given a unique url followed by a code, ie: The DB is setup as such; email_id email code ts 1 [email protected] 98VIB1

  • Insert NULL values to MySql records using MySqli 2011-04-15

    My page sends using ajax data to a php script. one of the vars that the script gets is: $product_disc now a small test that I have done inside the script clearly revealed that $product_disc is null. the test: if ($product_disc == null) {$test="null";

  • Interacting with dialogs in VS2010 with the Macro Recorder (using Visual Studio Macro Recorder to enter keystrokes automatically) 2011-06-16

    In one of my other questions, I inquired about a shortcut to enable a particular feature in the VS2010 IDE. It looks like the only way to make it happen is through the Macro Recorder, which I have unfortunately never used (as it looks quite powerful!

  • Deleting the oldest record using SQLite 2012-04-23

    I want to delete the oldest record from a table using SQLite so should i use a condition (the lowest id ) or there is another remedy --------------Solutions------------- delete from table1 as a where = (select min(id) from table1) or if you have

  • Limit number of records using trigger and constraints in MySQL 2012-03-08

    I have a table called BFFs, that stores userID, and best friend's userID and I would like to restrict that table to have exactly 3 number of best friends for each different user. I mean if the table structre is: BFFs(userID, userID) and records are:

  • Update existing mysql record using php 2011-04-04

    Trying to update existing records in phpMyAdmin, but the following code doesn't seem to be working. <?php $id = stripslashes($_POST['id']); $title = stripslashes($_POST['title']); $first = stripslashes($_POST['first']); $surname = stripslashes($_P

  • Get MySQL Record using Php & JQuery 2011-04-19

    Here's my scenario: I have a drop down menu, with different values. When option 'A' is chosen, I want it to use JQuery to call a Php script. That Php script will make a database query which returns a record ID. When that record ID is returned to the

  • how to take away the time and seconds from the database records using sqlcmd? 2012-01-18

    "2011-12-26 00:00:00.000" The record is from my database table . How do i remove the hours, minutes and mini seconds using sql CMD? --------------Solutions------------- Since you are using SQL Server 2008, you can cast to the new data type "date". SE

  • Insert multiple Mysql record using Array 2012-03-03

    i have an array of company name, i insert each company name as separate record.below is the code <input type="text" name="company_name[]"> $company_name = $_POST['company_name']; if($company_name) { foreach($company_name as $company) { $mycompa

  • Delete Mysql record using array 2012-03-07

    I am trying to delete multiple record(s) by using codeigniter $this->db->delete() and $this->db->where() I want to delete record(s) with an array like $id =array( 0=>'13', //13 is the id 1=>'4', //4 is the id 2=>'2' //2 is the id

  • How to poll database and trace the latest record using java? 2011-07-23

    I have a situation where user upload a new file when file successful submitted then one records is inserted into database table.i will run other class,that poll database if new records is inserted retrieve file name then read file and insert all file

  • How can I get the MySQL fields using PHP with one query? 2011-12-07

    Basically, I have two tables (copied from WordPress): users and user_meta. User_meta has 4 columns: meta_id, user_id, meta_key, meta_value. Each row has an unique meta_id, but multiple rows can have the same user_id. I want to get everything from use

  • extra spaces while updating the mysql database using php 2012-04-24

    i am sending two array list for example [P,Q,R,S,T,U,V] and [A,B,C,D,E,F,G] from android to php through url. On updating [P,Q,R,S,T,U,V] is replaced by [A,B,C,D,E,F,G] and updating taking place correctly. but in mysql database while updating first ro

  • Limit the size of disk space used by continuous integration builds 2011-02-24

    Context My application is divided into 10 libraries, 5 web applications, and 20 batches (which can be considered as a JAR library, as their assembly is not automatically created when running a mvn install command). The structure is as follow: my-proj

Copyright (C), All Rights Reserved.

processed in 0.076 (s). 11 q(s)