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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:31:26+00:00 2026-05-17T18:31:26+00:00

I am displaying a list. The user can edit any item. I am displaying

  • 0

I am displaying a list.

The user can edit any item.

I am displaying next previous buttons which when clicked it dynamically fetches the next previous records form db. no page reload.

this is working well with id. like how can i get next and previous field id with php from mysql and MySQL next/previous ids (arbitrary sort order)

Currently i am displaying like

select * from table order by name asc

and for next and previous i used like this…

select * from table where id > $id order by name asc limit 1
select * from table where id < $id order by name desc limit 1

the above is what i got when i searched the internet.

in this order the id will not be in an order so i cannot use id to fetch next and previous record i think so.

i want to get next and previous records with respect to any other field and not by id.

so some thing like this.

select * from table where id > 5 order
by name asc or desc limit 1.

what would be the query?

Note

There are 15000 records. which is half filled by default. the rest half is supposed to be updated by admin. so instead of reloading the page after the admin had updated one record i fetch the other and show dynamically on the screen so that he can continue updating content. there will not any page reload. he just clicks update and the next record appears. he can select previous or next button to navigate between records.

  • 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-17T18:31:27+00:00Added an answer on May 17, 2026 at 6:31 pm

    You need to filter on the value of name:

    SELECT * FROM `table`
    WHERE name < 'Foo'
    ORDER by name DESC
    LIMIT 1
    

    This only works if the names are unique. If there can be duplicates you need a tie-breaker. You can for example use the id column to tie-break.

    SELECT * FROM `table`
    WHERE name < 'Foo' OR (name = 'Foo' AND id < 42)
    ORDER by name DESC, id DESC
    LIMIT 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have list of items in my activity which I load dynamically, item after
Im having problems displaying records to my view when passing viewdata to a user
I have a list of user comments stored in a database and I'm displaying
I am trying to dynamically create a list of radio buttons that represents the
I have a list of items that I am displaying in a floated list,
I am displaying many rows of data in a list view that is bound
I have ObservableCollection<Foo> that is bound to an ItemsControl (basically displaying a list). Foo
I have created a Custom Edit Form for a custom list using SharePoint designer.
I currently have a user control that is used on both an /Address/Edit and
I am displaying a list of data in the following manner; Surname Forename Email

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.