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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:52:34+00:00 2026-05-16T15:52:34+00:00

In one of my current projects I have a dropdown (select) form element. I

  • 0

In one of my current projects I have a dropdown (select) form element. I populate the options using an array (PHP):

$regions=array(
    1=>'North West',
    2=>'North East',
    3=>'South West',
    4=>'South East',
);

(array key=option value, array value=option text)

Now this offers me the convenience of being able to re-order the options as I wish.

The problem is now my client wants to be able to add/modify/re-order options from an admin interface. This means I now need to put these options in to a database table.

What that also means is that there is no easy way (not that I’m aware of) of putting the records in a custom order.

Let’s suppose I create a regions table that includes a ‘sort_order’ field. Does anybody know of any solutions that will allow the client to re-order the records from an interface using simple up/down buttons?

  • 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-16T15:52:34+00:00Added an answer on May 16, 2026 at 3:52 pm

    The only way to represent ordering in a relational database is by designating a field that defines the order, as you suggested with the sort_order field.

    In your admin interface, you could have your up/down buttons trigger a JavaScript function (assuming a web application) which would iterate through the newly ordered regions and assign an incrementing integer to each one. This integer can be assigned to a hidden field for each region, and posted with the full form data when changes are saved.

    Upon posting the form, you can simply insert/update the records in the database, with the sort_order field as it was calculated on the client-side.

    Getting an ordered result set from a database is usually quite straightforward:

    SELECT * FROM your_table ORDER BY sort_order;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.