Need help with simple code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bob Bedford

    #1

    Need help with simple code

    Hello there,

    Little problem I can't solve. Its seems easy but I can't find out a simple
    solution. Maybe a clever way already exists:

    I've a site where people may have up to 5 pictures.
    They can add, remove, change pictures as they want. The problem is when
    users remove pictures at beginning and in the middle.

    User X uploads 5 pictures.
    Then he decides to remove picture 1 and 3.
    Actually the resulting pictures are 2, 4 and 5.

    I want to move (by renaming) the pictures to have finally 1,2,3

    How can I do this ? Pseudo code would be great, as Actually I'm trying to
    look in 2 array to keep trace where they are free slots and used pictures
    and trying a complex move between array. Isn't a good way, I know, but I
    can't find a easy way.

    Bob



  • goling@gmail.com

    #2
    Re: Need help with simple code

    Well the siplest way ( I think ) would be to include the shifting
    process into the delete function. So when you delete image 2 then you
    will run through a loop that runs from 3-5 and shift them all so the
    result will be 2-4. BUt since I dod not quite know how your code is (
    if you allow more than 1 deletation at a time ) I can not quite tell
    you the solution, since if you are deleting2 files at a time you have
    to run the proccess 2 times ( or something like that ).

    Hope this answares some of your questions ( although it raised some
    more in my mind, :p ), and hope I undestood your question. :)

    Ásgeir

    Comment

    • Bob Bedford

      #3
      Re: Need help with simple code

      <goling@gmail.c om> a écrit dans le message de news:
      1141828588.2434 61.228560@z34g2 00...legr oups.com...
      Well the siplest way ( I think ) would be to include the shifting
      process into the delete function. So when you delete image 2 then you
      will run through a loop that runs from 3-5 and shift them all so the
      result will be 2-4. BUt since I dod not quite know how your code is (
      if you allow more than 1 deletation at a time ) I can not quite tell
      you the solution, since if you are deleting2 files at a time you have
      to run the proccess 2 times ( or something like that ).

      Hope this answares some of your questions ( although it raised some
      more in my mind, :p ), and hope I undestood your question. :)

      Thanks for your answer...

      It's finally done, with less than 10 lines of php code...



      Comment

      • goling@gmail.com

        #4
        Re: Need help with simple code

        NIce hope my answare helped u a little.. ;)

        Comment

        • Bob Bedford

          #5
          Re: Need help with simple code

          <goling@gmail.c om> a écrit dans le message de news:
          1141946502.9103 49.36910@v46g20 00...legro ups.com...[color=blue]
          > NIce hope my answare helped u a little.. ;)[/color]

          Of course it did !

          Thanks for your help.

          Bob



          Comment

          Working...