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

  • Home
  • SEARCH
  • 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 6719125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:03:20+00:00 2026-05-26T09:03:20+00:00

I am currently building a web application (a media player) using Javascript, PHP and

  • 0

I am currently building a web application (a media player) using Javascript, PHP and MySQL. It will be used to upload videos and store them into a playlist, which can then be used by the user to place the videos in the desired order.

Uploaded files a saved in a MySQL database (id, title, file name and location, …). The question is, how can I save the order in which the user puts the playlist?

I don’t think adding a “position” field in the database is a good idea, as too many queries will be ran with each update. I thought of a “next” field, which points to the id of the next video in the list, which would “only” require a maximum of 3 queries for each update (right?).

Is there a better way to store the order of the playlist? It doesn’t particularly have to be in the database, it could be a text file as well I suppose.

Suggestions?

Thanks!

  • 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-26T09:03:20+00:00Added an answer on May 26, 2026 at 9:03 am

    I think a ‘position’ field would be OK. You could update it with one statement after changing a track position, like this:

    UPDATE track SET position=(CASE 
        WHEN position > :oldPos AND position <= :newPos THEN position - 1 
        WHEN position < :oldPos AND position >= :newPos THEN position + 1
        WHEN position = :oldPos THEN :newPos
        ELSE position
    ) WHERE playlist_id = :playlist_id
    

    When inserting a new track just set :oldPos to a big value (bigger than any position on the list, so for example list length + 1) and :newPos to inserted track position, when removing a track set :oldPos to removed track position and :newPos to a big value.

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

Sidebar

Related Questions

I am building a web application that is currently PHP with MySQL. There is
I am currently building a small web application for publishing stories using PHP and
I am currently building a gallery web application using php. I am currently developping
I am currently building an internal web application used in a factory/warehouse type location.
I'm currently building a small web application that includes a fair amount of JavaScript.
I'm currently building a simple web application in PHP that other company's can use
I'm currently building a SmartGWT-based web application (using the Portlet Layout). So I have
I am building a rather larger web application with javascript and PHP. The app
I currently building web management system using mvc3 In my application i have system
I am building a secure web application. Currently, my application runs well using http

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.