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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:08:42+00:00 2026-05-26T14:08:42+00:00

I have a mysql database and some php that allows you to create an

  • 0

I have a mysql database and some php that allows you to create an entry in the database, update an entry, and view the entries as a web page or xml. What I want to do is add a function to move an entry in the database up or down by one row, or, send to the top of the database or bottom.

I’ve seen some online comments about doing this type of thing that suggested doing a dynamic sort when displaying the page, but I’m looking for a persistent resort. I’ve seen one approach suggested that would be to have a separate “sort” field in the database that is agnostic of the actual database sort key, but I’m not sure why that would be better than actually re-ordering the database

Here is a dump of the table structure:

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `hlnManager`
--

-- --------------------------------------------------------

--
-- Table structure for table `hln_stations`
--

CREATE TABLE IF NOT EXISTS `hln_stations` (
  `id` int(6) NOT NULL auto_increment,
  `station_title` varchar(60) NOT NULL default '',
  `station_display_name` varchar(60) NOT NULL default '',
  `station_subtitle` varchar(60) NOT NULL default '',
  `station_detailed_description` text NOT NULL,
  `stream_url_or_playlist_url` text NOT NULL,
  `link_type` varchar(25) NOT NULL default '',
  `small_thumbnail_graphic_url` text NOT NULL,
  `large_thumbnail_graphic_url` text NOT NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;
  • 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-26T14:08:42+00:00Added an answer on May 26, 2026 at 2:08 pm

    Not sure what you mean by “Reordering” the database… SQL Databases typically do not make any guarantees on what order (if any) they will return records in short of an ORDER BY clause.

    1. You need a “SortOrder” type column. I suggest you make it an int with a unique key.
    2. You need a way to update this “SortOrder” column via the UI

    Easy to program, easy to use: Implement a simple drag+drop interface in HTML using jQuery or whatever javascript library works for you. In the on-complete method (or in response to a save button), trigger an ajax call which will simply send an array of ids in the correct order. On the database side, loop over it and update the SortOrder accordingly, starting at 1, then 2, etc…

    Harder to program, hard to use: Implement a classical move-up and move-down buttons. When clicked, send the id and action (eg, up, down) to the server. There are several strategies to handle this update, but I will outline a couple:

    Assuming the user clicked “move up”, you can swap IDs with the previous record.

    Find the previous record: SELECT id FROM hln_stations WHERE SortOrder < (SELECT SortOrder FROM hln_stations WHERE id = ...) ORDER BY SortOrder DESC LIMIT 1

    Run two update statements, swapping the SortOrder. Reverse for moving down. Add special code to detect top or bottom.

    etc…

    There are other ways, but for a web interface, I suggest you do Drag+Drop, as the users will love it.

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

Sidebar

Related Questions

I have a PHP server script that SELECTs some data from a MySQL database.
I have a 'price' variable that contains some integer number from a MySQL database.
I have some MySQL database server information that needs to be shared between a
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have a MySQL database of keywords that are presently mixed-case. However, I want
I have a MySQL database that I want to archive . What is the
I have a table generated from some PHP code that lists a SMALL amount
I have a MySQL database with some URLs in it. One URL per row.
I took over some old php application with MySQL as database. Inside the database,
I wrote some PHP code that will allow me to create an html dropdown

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.