SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    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
    Posts
    502
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why dont you do something like this

    Code:
    <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++ ) {
        
    $db->query
            
    "UPDATE myTable 
             SET position = " 
    . (int)$_POST['elementPosition'][$i] . "
             WHERE id = " 
    . (int)$_POST['elementID'][$i] );



Bookmarks

Posting Permissions

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