Jump to content

Archived

This topic is now archived and is closed to further replies.

Guest convention

Reorder MySQL rows via PHP?

Recommended Posts

Guest convention
I have a webpage that displays all of the MySQL rows in descending order. Though I don't know if this matters, all rows have a unique id number (auto_increment, primary key). I am wondering, is it possible to reorder any entry in MySQL in PHP (such as a form, GET, or any other method)? For example, move a row from the bottom of the page to, say somewhere in the middle?

I don't really want to do it by using the 'ORDER BY' SQL statement, but rather actually move the rows in the MySQL database.

Thank you for the help. :)

Share this post


Link to post
Share on other sites
Sorry, but that's just stupid. That's the whole purpose of the ORDER BY statement. If you have data that you want ordered in a specific way that cannot be achieved using ORDER BY then you should add a "sort" column to the data and then ORDER BY that.

And, the only way to reprder the rows would be to create a script that would overwrite all the records in the order you want. Again, bad idea.

Share this post


Link to post
Share on other sites
perhaps you need to be a bit clearer.  Are you for instance, wanting to have a list of stuff that you want to be able to move up and down the list, such as, on a message board, having say 10 forums, and being able to move a forum up or down the list?

if so, then what you will want to do is create another field in your table called "layout_order" or other some such descriptive thing.  Then you will want to in your query, order by layout_order.  If you want to "bump" the item up a notch, then you would swap numbers with the it and the one above it. 

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.