0

I'm trying to implement dragable sorting and saving the order to mysql using php and jQuery. Here's the scenario. Say, I have 3 items listed as Messages, Disputes and Services.

  • Messages:
    msg1
    msg2
    msg3...

  • Disputes:
    disp1
    disp2
    disp3...

  • Services:
    ser1
    ser2
    ser3...

the information shown above is coming from 3 different tables in mysql database.

I need drag and drop to sort the three sections Messages, Disputes and Services. Also I need to save the sorted order in the database.So the next time the page shows the sections with the saved sort order. Can anyone help me in this?

I have gone through many examples that saves the sorted order, but these examples are saving the static data in to database along with sort order.

Dynamic Drag’n Drop With jQuery And PHP

1
  • Is there any particular reason you need to store it in a database? Would storing it client-side in a cookie be ok as well? Commented Dec 15, 2011 at 12:11

1 Answer 1

1

I don't know what drag-and-drop you will be using, but you will want to add an event when an item is dropped. Something like:

...,
drop: function() {
    string order = GetorderofElementsinContainer("ContainerID");
    $.ajax({
        type: "post",
        url: "whatmethodtocall",
        data: "order=" + order,
        success: function (data) {
            alert("Yippee, the order is saved!");
        }
    });
},
...  

This will automatically trigger an update whenever you change the order. You'll have to check how to get the order and how to store it, but as I have no info on that, I can't help you there ;)

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Flater... thanks for your response... I have followed something similar to your suggestion and its working fine now. Thanks a lot for your suggestion
Happy to give back to the comunity that has helped me countless times ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.