zero-perfoliate
zero-perfoliate

Author Topic: Assigning/arranging relational numbers to an array  (Read 228 times)

Offline blargalarg

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Assigning/arranging relational numbers to an array
« on: August 27, 2009, 02:08:14 PM »
Hi all!

I've been writing PHP code for quite a few years now, but I think I've just gotten in over my head. I'm a decent programmer, but I'm by no means a master.

I'm trying to write some code that will allow a user to arrange a group of links by their own preferance. The links are stored in a database, and I'd like to store a numerical value in the database as well to sort the links when the user views them (ie: link 1 goes at the top, link 2 underneath that, etc...).

Here's my problem: I'd like to make it as easy as possible on the user. If the user decides to move 'link 4' to the 'link 1' position I'd like the code to auto-adjust all the way down - filling the gaps - and then storing the new values in the database.

I'd guess my core question would be: How do I go about modifying the array to auto-arrange numbers and fill any gaps?

Any help, pointers or tips would be greatly appreciated. Thank you for reading this!

-Jack

 

zero-perfoliate