Re: Multiple multiple selects
| From: | Steff Osborne | Date: | Mon, 17 Jul 2000 05:46:42 +0000 |
| Subject: | Re: Multiple multiple selects | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6873@lists.php.net to get a copy of this message | ||
Well, here's my code, which looks like it should work when help up against yours and Ray Street's:
Printing the form -- the select box is printed over and over, so long as there's stuff in $statrow:
<?
$loop = 0;
while ($statrow = mysql_fetch_array($statsql)) :
$loop++;
?>
<select name="othermem<? echo $loop; ?>[]" size="5" multiple> // Start select box
<?
$userssql = mysql_query("SELECT ID, FirstName, LastName FROM Users
ORDER BY FirstName");
while ($usersrow = mysql_fetch_array($userssql)) :
printf("<option value=\"%s\"> %s %s\n", $usersrow["ID"],
$usersrow["FirstName"], $usersrow["LastName"]);
endwhile;
?>
</select>
<?
endwhile;
?>
Processing the form contents:
<?
$num = count($statID);
for ($i = 0; $i < $num; ++$i) {
$arrayName = "othermem" . $i;
if (isset($$arrayName)) {
while (list ($key, $val) = each ($$arrayName)) :
$sql = mysql_query("INSERT INTO ProjectMembers (ID, StatusListID,
UserID) VALUES (NULL, '$statID[$i]', '$val')");
endwhile;
}} ?> The error I'm getting is that $$arrayName is not an array. Any suggestions would be greatly appreciated. This thing has been driving me nuts for a week!!! Thanks again, -- Steff Osborne Sequential Tart Webzine http://www.webslayer.net/steff/ http://www.sequentialtart.com