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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:47:09+00:00 2026-06-12T15:47:09+00:00

I have a variable number of rows in a mysql table. I want to

  • 0

I have a variable number of rows in a mysql table. I want to change the order they appear, irrespective of the content of any significant column, what’s the best way to do it?

For example, if I have:

id , content, order-by
1  , d      , 1
2  , a      , 2
3  , v      , 3
4  , i      , 4
5  , d      , 5

and want to reorder the fields to:

id , content, order-by
3  , v      , 1
4  , i      , 2
5  , d      , 3
2  , a      , 4
1  , d      , 5

which sorted by id would look like:

id , content, order-by
1  , d      , 3
2  , a      , 4
3  , v      , 1
4  , i      , 2
5  , d      , 5

The complication is that I have to manually or programmatically update each other row affected by a change in order, deletion or addition. Isn’t there some built in functionality or script someone already has done to save some time on this?

Thank you in advance for your time.

  • 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-12T15:47:10+00:00Added an answer on June 12, 2026 at 3:47 pm

    Whenever your program changes the order, you will have to update the order_by column with the correct order_by value. I had worked on a program with an assembly in which page orders can be changed by drag and drop. The positions will be held in JS variables, till time to save. On submit, the revised order will be updated in the table.

    When you access the table you have to do :

     SELECT * from table order by order_by;
    

    It all depends on the size of your table though, and what you are trying to achieve with the order.

    As @Matt Gibson mentioned in the comment, if you are trying to implement a drag and drop ordering of a list, you can use jQuery UI Sortable . You can achieve something like –

     var result = $('#sortable').sortable('toArray');
     $.post(
            url,
            "order="+result
     );
    

    Receive the position values in the PHP url, and process it.

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

Sidebar

Related Questions

I have a variable number of table rows (n), and I would like the
I have a form that has 8 columns and a variable number of rows
I have the MySQL table with 2 rows that is name for user name
I am trying to create a table which can have a variable number of
I have a table with 3 columns containing a variable number of records based
I have a MySQL table with a number of columns, including one called 'Name'.
How I can have variable number of parameters in my function in C++. Analog
I have a variable number of points on a canvas. Sometime its four other
I have strings that contain a variable number of leading hyphens and which may
I have a PHP function that takes a variable number of arguments (using func_num_args()

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.