Home > Archive > PERL Beginners > March 2005 > placeholder alteration
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
placeholder alteration
|
|
|
| Hi all, I'm rather puzzled over this, tried a few things but nothing ever
worked satisfactorily.
I've got an sql database with a table 'sideblocks' that represents objects
on a webpage. More specifically blocks of text/links that appear at either
side of the page. A column in that table is a place number called 'pos'
which represents the position of the block on the page, i.e if pos = 1 then
it's at the top, pos = 2 is underneath it, etc.
I have to write a web based tool that enables you to move blocks up and down
amongst themselves. But I'm stumped over a method. Everything I've tried so
far either messed up all the position numbers, or didn't work at all.
Basically, the web form provides a box to type in a position number, and
when it's submitted, it sends the perl script into a routine that goes
through the database re-arranging all the position numbers. So if block 5
was selected for editting, and was told to go to position 2, when the script
runs through the database, 1 stays where it is, the current 2 is moved to 3
and 5 is placed in position 2, then 3 is moved to 4, and 4 is moved to 5. In
reverse, if 1 was told to go to position 4, 2 would move up to 1, 3 would
move to 2, 4 would move to 3, the old 1 would be put in position 4, and 5
would remain unchanged.
At some points I've managed to master moving blocks up from bottom to top,
but not the other way around as well!
Does anyone have any hints or tips on the best way to go about this? I'm
currently scratching my head real hard now to a point where I think I'm
losing hair!
Many thanks,
Dan
| |
| Charles K. Clarkson 2005-03-20, 8:55 am |
| Dan <mailto:dan@danneh.org> wrote:
: At some points I've managed to master moving blocks up from
: bottom to top, but not the other way around as well! Does
: anyone have any hints or tips on the best way to go about
: this? I'm currently scratching my head real hard now to a
: point where I think I'm losing hair!
Can you show us the relevant code where you have had this
success? It would help me understand what your data structure
and such look like.
Are you trying to move things about incrementally or all
at once. For example, if the web user wants to move position
5 to position 3 does she have to first move position 5 to
position 4 and THEN move position 4 to position 3 or
is she allowed to just do it in one move?
What does the form to move positions look like? What form
fields are being returned to the script?
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
|
|
|
|
|