Re: Multiple multiple selects
| From: | Erik | Date: | Mon, 17 Jul 2000 07:20:57 +0000 |
| Subject: | Re: Multiple multiple selects | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-6882@lists.php.net to get a copy of this message | ||
Steff,
What is $$arrayName supposed to accomplish code-wise?
As a variable variable named 'arrayName' what value of
$arrayName[ ] do you expect to be referring to?
What I'm suggesting is to deconstruct the compressed notation
you are using and obviate your logic more clearly. You're on the
edge of crypto-perlisms here and jamming harder into it is not
likely to make it clearer. Strip it down, lay out the guts, type a
lot more clear simple stupid code and see what shows up in
broad daylight.
I always try to take three small steps rather than voluntarily build
up arrays of variable variables ...
Regards,
Erik Stainsby
network tech by day
php hacker by night
beer drinker at any time
----- Original Message -----
From: "Steff Osborne" <sosborne@xuma.com>
To: "Steve Edberg" <sbedberg@ucdavis.edu>; <php-general@lists.php.net>
Sent: Sunday, July 16, 2000 10:46 PM
Subject: Re: [PHP] Multiple multiple selects
> 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
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>