PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Creating Sortable Lists With PHP And Ajax

Article Comments (18 total)

Displaying article comments 1 to 10 of 18
John Hansen, 18 September 2009

Great Tutorial, I was wondering how you can get additional fields to display on each line. eg. say title and add a line for year. Thanks in advance.


Martin, 5 March 2009
Simply... WOW!! This was exactly what I was searching for soooo long! Your tutorial is very well explain and very clear. Thx again for this great knowledge sharing :) Peace

steve, 20 April 3633
Very good script and even better tutorial. However with long lists it bumps up against the bottom (or top) of the page. Anyway to get it to automagically scroll like Word and Excel does? My list can be 100 items long (description of pictures to order) and its a real pain to only be able to drag them only a page at a time. -thx-

Pranami, 14 April 2008
Thank You very much. The script simple enough to understand as well as implement. It was really very helpful.

Pranami, 8 April 2008
Thank You very much for this article. The script is both easy to understand and useful at the same time. I had been looking for it for a while, and this really helped.

Belal, 15 November 2007

Thank you very much for the article. For the past 10 months I have been looking for this script. I have developed a application for a client. They said we want have specific items to appear at the top as they needed the most. I wanted to work on a very complicated drop down menu; but could not do it. This is exactly what I wanted. Now the user can arrange the list in any way he wants.


Audrey, 6 November 2007

This is such a cool script. I can't believe I'm the first person to comment on it. I have a wrinkle for you that I can't figure out because I'm so new to both Ajax and Scriptaculous.

This example works great if you're sorting every record in your database, but I only want to sort segments of it at a time (I use another table to pull the various subsets of records). I want to create a user interface that allows someone to select a subset via a $_REQUEST variable, and sort only those few records, and then request another subset, sort only those, etc.

The records will only display w/in their subsets so the rolling sort order does not matter, just how it sorts with like records.

The problem comes in with passing the $_REQUEST variable to the update fuction. I can display the subsets just fine, but when I actually update them, it only updates the records called in the first request variable I've chosen, and doesn't reset with each new $_REQUEST. Can you help? Do I make it a Session variable instead?


jv, 15 August 2007
Thanks... this is a great (and easy to understand) tutorial. The only thing is I want to make this work with table rows... any way to do that? Also, I'd like to pass parameters to each of the functions to make this all more modular... but troubleshooting is not easy when this ajax stuff does so much "behind the scenes"... Any thoughts?

Clint, 15 June 2007
Great article! I was just wondering though, what would happen if the list gets altered. First you have these entries: 1. Boondock Saints 2. Shawshank Remption 3. Green Mile 4. Anchorman 5. The Pianist Now, let's say you remove number 4 from the list and you load the AJAX ranking script. It would display: 1. Boondock Saints 2. Shawshank Remption 3. Green Mile 5. The Pianist How do we get the 5 to be 4? Its not that hard if there is just one link to be altered. Just remember the MAX(ranking) and then do -1, but what if you have a list of 20 movies and number 4 gets deleted. It would get messy. Do you (or anyone else) have a solution for that?

Ruben, 7 May 2007
Great tutorial. When I tested the index.php, I needed to add an "echo" for each variable inside the tag (movie_id and title) in order to get displayed the value.
Submit a Comment
Use the following form to submit a comment for this article. You can include any required code snippets, which we will format and highlight accordingly.


Note: Before your comment appears on PhpRiot, it must be manually approved. The email address field is optional. If you choose to include it, it will be displayed obfuscated to protect it from spammers.

In This Article