mccdave Posted December 23, 2007 Share Posted December 23, 2007 Hello all I need a little help with the following guestbook style application: http://www.mickleovercommunitycentre.co.uk/TESTING/guestbooknodate/ Is there any code i could use to move separate enteries up or down in the guestbook? login on the page is admin. Any help would be great as I cannot write code! Thanks Dave Quote Link to comment https://forums.phpfreaks.com/topic/82935-moving-enteries-updown-in-a-guestbook/ Share on other sites More sharing options...
drummer101 Posted December 23, 2007 Share Posted December 23, 2007 add a field to your mysql table that is an integer, and SORT BY `order` DESC. If you want to move the guestbook entry up, increase the value of the entries $order variable +1, down -1 Quote Link to comment https://forums.phpfreaks.com/topic/82935-moving-enteries-updown-in-a-guestbook/#findComment-421806 Share on other sites More sharing options...
xiao Posted December 23, 2007 Share Posted December 23, 2007 It's best to do -1 for up and +1 for down, so you can sort ASC and when u add a new entry, just give it the order-of-the-last-entry+1 You would also have to change the order of the entry above the one you move up to -1. And +1 with the one under down. I'll explain: List: Entry 1 [uP][DOWN] (order=1) Entry 2 [uP][DOWN] (order=2) Entry 3 [uP][DOWN] (order=3) If you click UP for entry 2, it's order becomes 1, but Entry 1 also has order 1, so you'll have to do Entry 1+1. Visa versa for DOWN. Quote Link to comment https://forums.phpfreaks.com/topic/82935-moving-enteries-updown-in-a-guestbook/#findComment-421817 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.