Hi there. I am trying to write a routine to allow me to sort the contents of a table by clicking on up or down arrows. The idea is that top record will have down arrow, bottom record up arrow and records inbetween both an up arrow and down arrow. Clicking the arrow causes the record to move up or down one row in the table. The hyperlinks on the arrows would be used to move the record up or down one by switching the sort order values in the records ie. you want to move a record one up, the value of the sort order would be switched with the record above.
I have created a numeric sort field that I initialize with the same value and the id field in my table. I have my database content in an array that I want to use. So I want to create the table using an array of rows. I can get something basic to work if I do a count of my array to get the first and last value. I do a foreach and test the values in a switch like: switch($itemcount) { case 1: if ($itemtotal == 1) { $arrows = ''; } else { $arrows = "$downarrow"; } break; case $itemtotal: if ($itemtotal == 1) { $arrows = ''; } else { $arrows = "$uparrow"; } break; default: $arrows = "$uparrow $downarrow"; break; } The problem I am having is to come up with a way to make this work when there is more than one field to sort on. I have a table with a list of functions and files. There is a many to one relationship between functions and files and I want the up and down arrows to work for sorting the functions in the files in the list. So that if a file has say 4 functions the first would be down arrow, next two records would have both arrows, last record for file uparrow, next record down arrow if file is different etc. Could anyone help by giving me some advice on the best way of getting something like this to work or have an example to follow. This would be helpful. I have checked the archives first but could not find anything. Regards, DAve -- Dave Pratt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php