Page 1 of 1

multidimensional array or another easier way???

Posted: Wed Dec 03, 2003 1:24 pm
by ericsodt
I have two arrays: $exArray and $sgArray.

$exArray contains groups like 5, 6,7, 8. and $sgArray contains subgroups like a, b, c, d, e, f, g.

Now heres where it get tricky. Group 5 has three subgroups a, b, c, d. and Group 6 has e, f, g.

How do I parse through the two array so that I can insert into the database the subgroups of that particular group? I was thinking something like $exArray[5]=array(a,b,c,d), etc...

anyone else with some thoughts about this??

I have done this in PL/SQL and javascript, but not too sure about PHP as I am new to it... but heres what I was thinking atleast in PL/SQL

htp.p(' <SCRIPT LANGUAGE = "JavaScript"> ');
htp.p(' // creating multidimensional array to hold ');
htp.p(' // the FY and max week per the AP ');
htp.p(' ');
htp.p(' // Populating Array with PL/SQL ');
htp.p(' var ArrayWK = new Array() ');
FOR curWKrec in curWKTYPE LOOP
vcnt := vcnt + 1;
IF vcnt = 1 then
htp.prn('ArrayWK['||curWKrec.fy||']=[-1,'||curWKrec.max_wk );
ELSE
IF curWKrec.fy != v_fy THEN
htp.p(']; ');
htp.prn('ArrayWK['||curWKrec.fy||']=[-1,'||curWKrec.max_wk );
ELSE
htp.prn(','||curWKrec.max_wk);
END IF;
END IF;
v_fy := curWKrec.fy ;
END LOOP;
htp.p(']; ');

Posted: Wed Dec 03, 2003 2:57 pm
by JAM
Not entirely sure what you mean, but here goes:

Code: Select all

<pre>
<?php
$exArray = array(
    5 => array('a','b','c','d'),
    6 => array('e','f','g'),
    7,
    8
);
print_r($exArray); // debugging
?>
</pre>

Posted: Wed Dec 03, 2003 3:47 pm
by ericsodt
Ok, this is hard to explain, but here I go.

I have a page (page 1) and on this page are groups. Under each group are some checkboxes (some groups have more than others). Now when I hit submit, I pass the checked values onto the next page. The problem is I can not pass the group those checked boxes fall into. So on page 2 I have to some how associate the checked boxes with what group they fall under.
ie.
Here this is a selectbox in group 0, subgroup 0, and set 1.
It just so happens that group0 has a group_id of '541'. Is there anyway to create an array or something like this Array[541] = 'selected checkboxes' and if so how would I do that?

Code: Select all

&lt;select name="g0_e0_s1" class="dropdown"  &gt;
      &lt;option selected value = -1&gt;&lt;/option&gt;
	   &lt;option value=15&gt;15&lt;/option&gt;
	   &lt;option value=14&gt;14&lt;/option&gt;
&lt;/select&gt;


I hope this explains more of what I am trying to accomplish

JAM wrote:Not entirely sure what you mean, but here goes:

Code: Select all

<pre>
<?php
$exArray = array(
    5 => array('a','b','c','d'),
    6 => array('e','f','g'),
    7,
    8
);
print_r($exArray); // debugging
?>
</pre>

Posted: Wed Dec 03, 2003 3:59 pm
by ericsodt
I'll try and explain better, I was reading what I wrote and you might not fully understand.

Here is how my HTML is laid out as the user sees it"

GROUP0
SUBGROUP0
- SET1
-a
-b
-b
- SET2
-a
-b
-b
- SET3
-a
-b
-b
SUBGROUP1
- SET1
-a
-b
-b
- SET2
-a
-b
-b
- SET3
-a
-b
-b

Now each set has a unique name like the first one is g0_sg0_s1, and under subgroup1, set 2 is called g0_sg_1_s2.

Now when I pass on the select box information onto the next page, which is where I will be inserting the infromation into the database, how do I associate what set 1-3 falls under, ie which subgroup?