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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:56:56+00:00 2026-06-02T13:56:56+00:00

Database: Table: news With the columns: Unique and Primary Key which auto increments called

  • 0

Database:

Table: news

With the columns: Unique and Primary Key which auto increments called ID, content and title


Code:

-> Creates a form with a textfield, where the user can put in his value for the ID and thus the position of the item

$form->textField("Position of the item item", "id", false, 30, false, getIfExists("id", $originalValues));

-> Posts the new ID as a query to the database

$queryvalues["id"]       = $_POST[ "id" ];

It works when I post an ID that isn’t in use by another item. However, if I try to overwrite an ID, it gives me an error and doesn’t change anything. Obviously, I’d need to update the IDs, so that it’ll increment all the conflicting IDs and thus allowing the edited ID to be posted.

I’m kinda annoyed as how to be doing this. I had the idea of adding an index number that defines the position, then switched to sorting the list with the database ID and changing the ID in the CMS will be able to update that whenever the user of the CMS wishes.

However, I’m not too sure how to approach this and whether there is a better option/solution.

Does anyone have any ideas/tips/hints?

I’ve tried using ON DUPLICATE KEY UPDATE, but I’m having no luck with it so far.


EDIT:

Alright, so ordering works now. I made a new column called Position and just used that to order the items with and it works fine.

However, if I add a new item, with a same position, it’ll put it under the other position. So basically the New “0” gets listed under the old “0”, while sharing the same key. Any suggestions on how to fix this? I was thinking of incrementing the old duplicate key. But have no idea how this would work exactly.

  • 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-02T13:56:58+00:00Added an answer on June 2, 2026 at 1:56 pm

    I understand that you want to use the ID to ordering your items : don’t do that.

    Instead, add a new columns named “ordering” :

    • When INSERT-ing an item, set this field value to the ID value
    • When UPDATE-ing the item position, swap the position value between the two items that are moving
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in my database the News Table which consist of => Id, Title,
I have a database table and one of the fields (not the primary key)
My database has news articles and blog posts. The primary key for both is
I have two tables in my database: NEWS table with columns: id - the
I have a database table containing the news on my site. It's divided into
Say I have at database table containing information about a news article in each
Which Database table Schema is more efficient and why? Users (UserID, UserName, CompamyId) Companies
In database table I have column called options . It has type of integer
I have a simple database table called Entries: class CreateEntries < ActiveRecord::Migration def self.up
I have a database table named call with columns call_time, location, emergency_type and there

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.