Guest convention Posted October 29, 2006 Share Posted October 29, 2006 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. :) Quote Link to comment https://forums.phpfreaks.com/topic/25457-reorder-mysql-rows-via-php/ Share on other sites More sharing options...
Psycho Posted October 29, 2006 Share Posted October 29, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25457-reorder-mysql-rows-via-php/#findComment-116157 Share on other sites More sharing options...
.josh Posted October 29, 2006 Share Posted October 29, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25457-reorder-mysql-rows-via-php/#findComment-116179 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.