Re: 2 dim array
| From: | Lutz Brueckner | Date: | Fri, 13 Oct 2000 17:39:35 +0000 |
| Subject: | Re: 2 dim array | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-3596@lists.php.net to get a copy of this message | ||
"Adv. Systems Design" <asd_2000@yahoo.com> wrote:
> I am passing a bunch of form values from
> HTTP_POST_VARS to $frm. There are some form values
> which are passed into $frm as an array already (i.e.
> glenum[])...So I am assuming that the array is passed
> into $frm and what I am getting is:
> $frm[name]=Jane Public
> $frm[address]=123 Main St.
> $frm[glenum][1]=Some value
> $frm[glenum][2]=some other value
> ...etc
>
> Is this correct?
Add a phpinfo() at the end of your page. In the output you
can see the HTTP_POST_VARS etc. and the format in which they
are passed to your script.
Or try print_r($frm) to inquire your array.
> The problem I am having is in traversing the
> $frm[glenum][] array and updating the db with those
> values...
>
> I tried this with no luck:
>
> $glearray = $frm["glenum"];
> while (list ($key1) = each ($glearray)) {
> while (list ($key2, $val) = each
> ($glearray["$key1"])) {
> $qid = db_query("
> INSERT INTO lesson_gle (l_id, glenum)
> VALUES ('$id', '$val')
> ");
> }
> }
I do not understand the need of the nested loops, isn't it
this what you want to do?
$glearray = $frm["glenum"];
foreach ($glearray as $val) {
$qid = db_query("INSERT INTO lesson_gle (l_id, glenum)
VALUES ('$id', '$val')");
}
Lutz
--
ibWebAdmin 0.2alpha *** web-based InterBase database administration
*** download the latest version from http://home.knuut.de/lb/ ***