wap3
12-08-2002, 02:12 PM
Hi guys,
I got a bit of a script I am trying to do which I need your help on.
Ok what is suppose to do is output a list in the following format.
group[1][0]=newOption("Access Platform (Hydraulic Access Platforms)","../php/list_items.php?subid=1&st=0&lm=4")
group[1][1]=newOption("Aluminium Tower","../php/list_items.php?subid=11&st=0&lm=4")
group[1][2]=newOption("Chimney Rigs","../php/list_items.php?subid=2&st=0&lm=4")
group[2][3]=newOption("Acrow Props","../php/list_items.php?subid=13&st=0&lm=4")
group[2][3]=newOption("Air Conditioners","../php/list_items.php?subid=12&st=0=&lm4")
and so on . .. .
Now what I have so far prints this out:
group[1]=newOption("Access Platform (Hydraulic Access Platforms)","../php/list_items.php?subid=1&st=0&lm=4")
group[1]=newOption("Aluminium Tower","../php/list_items.php?subid=11&st=0&lm=4")
group[1]=newOption("Chimney Rigs","../php/list_items.php?subid=2&st=0&lm=4")
group[2]=newOption("Acrow Props","../php/list_items.php?subid=13&st=0&lm=4")
group[2]=newOption("Air Conditioners","../php/list_items.php?subid=12&st=0&lm=4")
But it also gives an error saying invalid foreach loop.
I am nearly there I guess but just can't figure it out completely.
I need to get rid of the error and add the extra numbers i.e. [1] so it says [1][0]
for the very first one and so on ...
This is what I have so far. Can you give me some advice or help me write it a little better.
$maincat = get_categories();
$maincount = count($maincat);
for ($i=0; $i<$maincount; $i++) {
$subcat = get_sub4_categories($i);
foreach($subcat as $res) {
echo "group[$i]=newOption(\"$res[Sub_name]\",\"../php/list_items.php?subid=$res[Sub_id]&st=0&lm=4\")<br>"; }
}
Thanks
I got a bit of a script I am trying to do which I need your help on.
Ok what is suppose to do is output a list in the following format.
group[1][0]=newOption("Access Platform (Hydraulic Access Platforms)","../php/list_items.php?subid=1&st=0&lm=4")
group[1][1]=newOption("Aluminium Tower","../php/list_items.php?subid=11&st=0&lm=4")
group[1][2]=newOption("Chimney Rigs","../php/list_items.php?subid=2&st=0&lm=4")
group[2][3]=newOption("Acrow Props","../php/list_items.php?subid=13&st=0&lm=4")
group[2][3]=newOption("Air Conditioners","../php/list_items.php?subid=12&st=0=&lm4")
and so on . .. .
Now what I have so far prints this out:
group[1]=newOption("Access Platform (Hydraulic Access Platforms)","../php/list_items.php?subid=1&st=0&lm=4")
group[1]=newOption("Aluminium Tower","../php/list_items.php?subid=11&st=0&lm=4")
group[1]=newOption("Chimney Rigs","../php/list_items.php?subid=2&st=0&lm=4")
group[2]=newOption("Acrow Props","../php/list_items.php?subid=13&st=0&lm=4")
group[2]=newOption("Air Conditioners","../php/list_items.php?subid=12&st=0&lm=4")
But it also gives an error saying invalid foreach loop.
I am nearly there I guess but just can't figure it out completely.
I need to get rid of the error and add the extra numbers i.e. [1] so it says [1][0]
for the very first one and so on ...
This is what I have so far. Can you give me some advice or help me write it a little better.
$maincat = get_categories();
$maincount = count($maincat);
for ($i=0; $i<$maincount; $i++) {
$subcat = get_sub4_categories($i);
foreach($subcat as $res) {
echo "group[$i]=newOption(\"$res[Sub_name]\",\"../php/list_items.php?subid=$res[Sub_id]&st=0&lm=4\")<br>"; }
}
Thanks