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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:15:55+00:00 2026-05-13T14:15:55+00:00

I have a client I am building a small CMS for. One of the

  • 0

I have a client I am building a small CMS for. One of the functions is that he would like to be able to pick the order in which images display on a page.

In my mySql Database I have a table called image_info with the fields:

index (auto incremented)

img_url

img_link

I was thinking of adding an additional field called img_order which would be an int that I would refer to to sort the data returned to my php script.

I’m not sure if that is the best way. I feel like I will have to be re numbering every entry in the database just to move one image up or down the list.

Is there a standard procedure for this type of function?

Thanks,
-J

  • 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-13T14:15:55+00:00Added an answer on May 13, 2026 at 2:15 pm

    I think that adding an img_order column is the easiest way, and it won’t be hard be to renumber the fields. For instance, if you’re adding a picture at img_order position 15, just insert it with that value, then run the following query:

    update image_info set img_order = img_order + 1 where img_order >= 15;
    

    If you’re removing an existing image, you’d have to decrease the img_order values for all images after that one:

    update image_info set img_order = img_order - 1 where img_order >= 15;
    

    And if you’re moving an image from one position to another, you’d have to increment the img_order for all images between the original and new position:

    update image_info set img_order = img_order + 1 where 
    img_order between (least($old_img_order, $new_img_order), 
    greatest($old_img_order, $new_img_order));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a whiteboard, which would have a server(teacher) and clients(students). Teacher would
I have a client who is building a business application that will be used
I'm building a small program that acts as an XMPP client and I am
I am building a small CMS for training content, on instruction of my client.
I am building a client's site in WP and have managed to get the
I'm building a Rails weblog for a client, and he wants to have a
We have client server based app which saves user related data into a zip
I've developed a small app for my client which is supposed to be released
I'm building a web-app that handles internal emails and other frequent small-to-medium sized chunks
i was building a new small website for an existing client, and thought about

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.