SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    0 Post(s)
    0 Thread(s)

    bulk update position

    I am trying to implement functionality to update the position of all the elements in in the form (which is a listing of all items in the database)

    So lets say each element in the database has a position-- then on 1 page i displayed all the elements and its position in a text box -- with something like

    <INPUT type="text" size="4" name=" positionID-12 " maxlength="4" value=" 10 ">

    <INPUT type="text" size="4" name=" positionID-23 " maxlength="4" value=" 20 ">

    then a user can switch around the number in the text boxes
    and then when the user presses update for each of these text box( position) elements I just loop thorugh
    and update -- what is the general technique for this.

    What I am descibing is just a mass update,

    Any help or input appreciated.

  2. #2
    SitePoint Evangelist
    Join Date
    Jan 2005
    0 Post(s)
    0 Thread(s)
    why dont you do something like this

    <input type='hidden' name='elementID[]' value='23' />
    <input type='text' name='elementPosition[]' value='4' />
    then you can update like so
    PHP Code:
    for( $i 0$n count$_POST['elementID'] ); $i $n$i++ ) {
    "UPDATE myTable 
             SET position = " 
    . (int)$_POST['elementPosition'][$i] . "
             WHERE id = " 
    . (int)$_POST['elementID'][$i] );


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts