OK, so this probably is a bit off topic, but the results of these actions
will be placed into a MySQL database. Close enough?

I have a <select multiple></select> object named list[] that is passing its
selected contents to an array. That part works fine. I can use a for loop to
grab all of the selected items. Where I'm stuck is that I want to get both
the value AND the text for any given <option> element and simply numbering
the items in the array 1-N based on the number of rows is not sufficient.


<select name="itemList[]" multiple>
        <option value="101">PHP For Dummies</option>
        <option value="102">PHP For Professionals</option>
        <option value="103">PHP For Gurus</option>

I want to be able to be able to get both the value property (101, 102, ...)
AND the text between the <option></option> tags. Currently, I'm only getting
the text between the <option></option> tags. Is there a PHP function that
allows me to get to both?

The code I use to get the contents of the array is as follows and it works
        $numrows = count($_POST["itemList"]);

        for ($i = 0;$i < $numrows; $i++)
                $thisItem = $_POST["itemList"][$i];
                $thisOrdinal = $i;
                $sql="INSERT INTO leveltwo (2contentID, parentID, 2content,
2ordinal) VALUES ('Null','$parentContentID','$thisItem','$thisOrdinal')";
                echo ("<p>Item ".$i." in the list is:
                echo ($sql);
                        or die(mysql_error());
                echo ("Insert done. Click <a

The general idea behind the functionality I'm after is that the user is
presented with a select list of items. The user then can reorder the items
to his liking and can alter the text of the individual select items. But I
need to preserve the original ID of the individual select items before the
user reordered or altered the text. That original value will be included in
the WHERE clause of the SQL query in the code above. All of the moving and
editing stuff works via JS. I'm just stuck on how to get the value AND the
text from each option. I searched the archives first and got close, but no

Any help is appreciated.

Rich Hutchins
Sr. Technical Writing Administrator
Getinge/Castle, Inc.
1777 E. Henrietta Rd.
Rochester NY 14623

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to