![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi there, What would be the most efficient way to have items displayed on a webpage sorted in the order a CMS administrator wishes? So for instance, lets say I have a table employee: CREATE TABLE `employee` ( `id` int(10) unsigned NOT NULL auto_increment, `image` varchar(255) NOT NULL default '', `name` varchar(100) NOT NULL default '', `age` int(10) unsigned default NULL, `description` text, PRIMARY KEY (`id`) ) The employees get displayed on a webpage, and the CMS administrator has the ability to move employees up and or down on that page in the CMS. How would I go about doing that? I'm hoping there is some solution in which I don't have to iterate through all employees and set a sort number. I have this faint memory of some mathemetic formula of trick that would only need one item to be changed (i.e. the item that is moved). Can't recall it though. Maybe my mind is playing tricks in that there is no such thing anyway. ;-) |
#3
| |||
| |||
|
|
amygdala wrote: Hi there, What would be the most efficient way to have items displayed on a webpage sorted in the order a CMS administrator wishes? So for instance, lets say I have a table employee: CREATE TABLE `employee` ( `id` int(10) unsigned NOT NULL auto_increment, `image` varchar(255) NOT NULL default '', `name` varchar(100) NOT NULL default '', `age` int(10) unsigned default NULL, `description` text, PRIMARY KEY (`id`) ) The employees get displayed on a webpage, and the CMS administrator has the ability to move employees up and or down on that page in the CMS. How would I go about doing that? I'm hoping there is some solution in which I don't have to iterate through all employees and set a sort number. I have this faint memory of some mathemetic formula of trick that would only need one item to be changed (i.e. the item that is moved). Can't recall it though. Maybe my mind is playing tricks in that there is no such thing anyway. ;-) If there is some encoding schema that allows you to update only one row, I think it will be to expensive to decode the sortorder during selection. One idea is to leave gaps in the sortorder so that it is possible to insert a new number between two items. Another idea is to use a first and secondary sortorder. Both ways will force you to renumber the sortorder every once and a while. /Lennart [...] |
![]() |
| Thread Tools | |
| Display Modes | |
| |