Results 1 to 4 of 4

Thread: Saving Values From List

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Saving Values From List

    Part of my admin features is to give users access to certain pages. I've used the code at http://javascript.internet.com/forms...swapper-2.html to move users from one list to another but don't know how to save all the values added to the second list into mySQL DB. Can anyone help?

    Thanks.
    Last edited by lintz; Sep 25th, 2004 at 04:15 AM.

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    What exactly do you need help with? Do you have your database and tables setup, or do you need help with that? Or do you just need help building the SQL query?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697
    Attached is an example of what i'm trying to do. I'm trying to get all the values in the right hand side list then loop through them and save each entry into my database.
    Attached Images Attached Images  

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Since I don't know how you have your database setup and how you're storing things in the table, I can't help you build the SQL query, but to loop the selected items, you'd do something like this:

    PHP Code:
    <html>
    <head>
        <title></title>
    </head>
    <body>
        <?php
            
    if (isset($_POST['submit'])) {
                
    // Loop each selected item:
                
    for ($i 0$i count($_POST['items']); $i++) {
                    
    // Output the selected item:
                    
    echo $_POST['items'][$i] . '<br />';
                }
            } else {
        
    ?>

        <form action="selection.php" method="post">
            <select name="items[]" multiple="multiple" style="width: 100px;">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
                <option value="6">6</option>
            </select>
            <br />
            <input type="submit" name="submit" value=" Save Changes " />
        </form>

        <?php
            

        
    ?>
    </body>
    </html>
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

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



Click Here to Expand Forum to Full Width