CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeCharge.Discussion

 Multidimension Array. Problem getting Post values from a section of the array using parameters.Quite large code extract

Print topic Send  topic

Author Message
david
Posted: 06/10/2003, 5:41 AM



Hi my problem is trying to read and/or updating a small section of an array.

I have the following show event on my form. It creates a set of input boxes
for entering clothing orders 1 box for each size/delivery combination in a
set and 1 set of boxes per colour/and garment length combination.

There are always 6 delivery dates and if a garment is available in 2 sizes,
2 lengths, 2,colours it will produce 4 sets of boxes each with a 6 Delivery
x 2 Size grid of boxes. The before update event correctly reads all the
values in the boxes and stores them in an array. So far no problem. The
problem is when i want to just see one colour/length combination at a time.
I follow the comment and uncomment instructions and pass $z (Colour) and
$y (Length) params to the form and the form correctly shows just the set of
input boxes for that colour length combination. I do the same for the
Update event however things then go wrong. Any update of 1 set of input
boxes deletes the data that was available to view in any other. I guess that
each time I update I replace the array that stores the data with a new
version. So how do i retain the array and just make changes as they are
entered in the input boxes.

All the functions work correctly and the loops name all input boxes
correctly. Sorry this is so long. Also as this is my first attempt at any
PHP better ways of doing any of the things this code does would be welcome.
Its easy to see that it looks a bit clunky and I am sure that there must be
better ways.

Many Thanks David

//Show Event
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////
//$z = get_param(Colour); //Uncomment
//$y = get_param(Range); //Uncomment
//$fldfldThisColour =$z; //Uncomment
//$fldfldThisRange =$y; //Uncomment

//INIT ARRAYS
$fldfldRatioID = Dlookup("tblOrders", "fldRatioID",
"fldOrderID=$fldfldOrderID");
$fldfldRatioHeader = Dlookup("tblRatio", "fldRatioHeader",
"fldRatioID=$fldfldRatioID");
$fldfldRatioPacks = Dlookup("tblOrders", "fldRatioPacks",
"fldOrderID=$fldfldOrderID");
$fldfldRange = Dlookup("tblOrders", "fldRange",
"fldOrderID=$fldfldOrderID"); //Comment Out
$fldfldColours = Dlookup("tblOrders", "fldColours",
"fldOrderID=$fldfldOrderID"); //Comment Out

$PacksArray = unserialize($fldfldRatioPacks);

$RatioHeaderArray = explode(" ", $fldfldRatioHeader);
$RatioRange = explode(" ", $fldfldRange); //Comment Out
$RatioColours = explode(" ", $fldfldColours); //Comment Out
//GET COUNTS
$maxR = count($RatioRange); //Comment Out
$maxC = count($RatioColours); //Comment Out
$maxH = count($RatioHeaderArray);

$Qty=$maxH;
$Tot=$maxH+1;
$Date=$maxH+2;
//Create Ratio Header Form Fields

for ($i=0; $i<$maxH; $i++){
$ratio = InputText(3,$RatioHeaderArray{$i},formstyle,Ratio.$i,10,0,1);
$RatioHeaders = $RatioHeaders.$ratio;
}

$fldHeaderR =
InputText(7,'',formstyle,'Headers',10,1,1).$RatioHeaders.InputText(3,'Qty',f
ormstyle,'Qty',10,1,1).InputText(3,'Total',formstyle,'Total',10,1,1).InputTe
xt(12,'Delivery',formstyle,'Delivery',10,1,1);
for ($y=0; $y<$maxC; $y++){ //Comment Out
for ($z=0; $z<$maxR; $z++){ //Comment Out

$PackABoxes=""; //Comment Out
$PackBBoxes=""; //Comment Out
$PackCBoxes=""; //Comment Out
$Singles1Boxes=""; //Comment Out
$Singles2Boxes=""; //Comment Out
$Singles3Boxes=""; //Comment Out

for ($i=0; $i<$maxH; $i++){
$PackA =
InputText(3,$PacksArray[0]{$i}{$z}{$y},formstyle,PackA.$i.$z.$y,10);
$PackB =
InputText(3,$PacksArray[1]{$i}{$z}{$y},formstyle,PackB.$i.$z.$y,10);
$PackC =
InputText(3,$PacksArray[2]{$i}{$z}{$y},formstyle,PackC.$i.$z.$y,10);
$Singles1 =
InputText(3,$PacksArray[3]{$i}{$z}{$y},formstyle,Singles1.$i.$z.$y,10);
$Singles2 =
InputText(3,$PacksArray[4]{$i}{$z}{$y},formstyle,Singles2.$i.$z.$y,10);
$Singles3 =
InputText(3,$PacksArray[5]{$i}{$z}{$y},formstyle,Singles3.$i.$z.$y,10);

$PackABoxes = $PackABoxes.$PackA;
$PackBBoxes = $PackBBoxes.$PackB;
$PackCBoxes = $PackCBoxes.$PackC;
$Singles1Boxes = $Singles1Boxes.$Singles1;
$Singles2Boxes = $Singles2Boxes.$Singles2;
$Singles3Boxes = $Singles3Boxes.$Singles3;
}
$fldPackABoxes = InputTextReadonly(7,'Pack
A',formstyle,'0',10,1).$PackABoxes.InputText(3,$PacksArray[0]{$Qty}{$z}{$y},
formstyle,PackAQty.$z.$y,10).InputText(3,$PacksArray[0]{$Tot}{$z}{$y},formst
yle,PackATotal.$z.$y,10).InputTextCalendar(12,$PacksArray[0]{$Date}{$z}{$y},
formstyle,PackADelivery.$z.$y,10);
$fldPackBBoxes = InputTextReadonly(7,'Pack
B',formstyle,'1',10,1).$PackBBoxes.InputText(3,$PacksArray[1]{$Qty}{$z}{$y},
formstyle,PackBQty.$z.$y,10).InputText(3,$PacksArray[1]{$Tot}{$z}{$y},formst
yle,PackBTotal.$z.$y,10).InputTextCalendar(12,$PacksArray[1]{$Date}{$z}{$y},
formstyle,PackBDelivery.$z.$y,10);
$fldPackCBoxes = InputTextReadonly(7,'Pack
C',formstyle,'2',10,1).$PackCBoxes.InputText(3,$PacksArray[2]{$Qty}{$z}{$y},
formstyle,PackCQty.$z.$y,10).InputText(3,$PacksArray[2]{$Tot}{$z}{$y},formst
yle,PackCTotal.$z.$y,10).InputTextCalendar(12,$PacksArray[2]{$Date}{$z}{$y},
formstyle,PackCDelivery.$z.$y,10);
$fldSingles1Boxes =
InputTextReadonly(7,'Singles1',formstyle,'3',10,1).$Singles1Boxes.InputText(
3,$PacksArray[3]{$Qty}{$z}{$y},formstyle,Single1Qty.$z.$y,10).InputText(3,$P
acksArray[3]{$Tot}{$z}{$y},formstyle,Single1Total.$z.$y,10).InputTextCalenda
r(12,$PacksArray[3]{$Date}{$z}{$y},formstyle,Singles1Delivery.$z.$y,10);
$fldSingles2Boxes =
InputTextReadonly(7,'Singles2',formstyle,'4',10,1).$Singles2Boxes.InputText(
3,$PacksArray[4]{$Qty}{$z}{$y},formstyle,Single2Qty.$z.$y,10).InputText(3,$P
acksArray[4]{$Tot}{$z}{$y},formstyle,Single2Total.$z.$y,10).InputTextCalenda
r(12,$PacksArray[4]{$Date}{$z}{$y},formstyle,Singles2Delivery.$z.$y,10);
$fldSingles3Boxes =
InputTextReadonly(7,'Singles3',formstyle,'5',10,1).$Singles3Boxes.InputText(
3,$PacksArray[5]{$Qty}{$z}{$y},formstyle,Single3Qty.$z.$y,10).InputText(3,$P
acksArray[5]{$Tot}{$z}{$y},formstyle,Single3Total.$z.$y,10).InputTextCalenda
r(12,$PacksArray[5]{$Date}{$z}{$y},formstyle,Singles3Delivery.$z.$y,10);


$RatioPacksOrdered =
$fldHeaderR.'<br>'.$fldPackABoxes.'<br>'.$fldPackBBoxes.'<br>'.$fldPackCBoxe
s.'<br>'.$fldSingles1Boxes.'<br>'.$fldSingles2Boxes.'<br>'.$fldSingles3Boxes
..'<br>';

$fldfldRatioPacksOrdered =
$fldfldRatioPacksOrdered.$RatioPacksOrdered.'<br>';
} //Comment Out
} //Comment Out

//UPDATE EVENT
////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////
$fldfldRatioID = Dlookup("tblOrders", "fldRatioID",
"fldOrderID=$fldfldOrderID");
$fldfldRatioHeader = Dlookup("tblRatio", "fldRatioHeader",
"fldRatioID=$fldfldRatioID");
$RatioHeaderArray = explode(" ", $fldfldRatioHeader);
$RatioRange = explode(" ", $fldfldRange); //Comment Out
$RatioColours = explode(" ", $fldfldColours); //Comment Out
//GET COUNTS
$maxR = count($RatioRange); //Comment Out
$maxC = count($RatioColours); //Comment Out
$maxH = count($RatioHeaderArray);

//$z = $fldfldThisColour; //Uncomment
//$y = $fldfldThisRange; //Uncomment
$Qty = $maxH;
$Tot = $maxH + 1;
$Del = $maxH + 2;


$PacksArray = unserialize($fldfldRatioPacks);

for ($y=0; $y<$maxC; $y++){ //Comment Out
for ($z=0; $z<$maxR; $z++){ //Comment Out
for ($i=0; $i<$maxH; $i++){

$PacksArray[0]{$i}{$z}{$y} = get_param("PackA".$i.$z.$y);
$PacksArray[0]{$Qty}{$z}{$y} = get_param("PackAQty".$z.$y);
$PacksArray[0]{$Tot}{$z}{$y} = get_param("PackATotal".$z.$y);
$PacksArray[0]{$Del}{$z}{$y} = get_param("PackADelivery".$z.$y);

$PacksArray[1]{$i}{$z}{$y} = get_param("PackB".$i.$z.$y);
$PacksArray[1]{$Qty}{$z}{$y} = get_param("PackBQty".$z.$y);
$PacksArray[1]{$Tot}{$z}{$y} = get_param("PackBTotal".$z.$y);
$PacksArray[1]{$Del}{$z}{$y} = get_param("PackBDelivery".$z.$y);

$PacksArray[2]{$i}{$z}{$y} = get_param("PackC".$i.$z.$y);
$PacksArray[2]{$Qty}{$z}{$y} = get_param("PackCQty".$z.$y);
$PacksArray[2]{$Tot}{$z}{$y} = get_param("PackCTotal".$z.$y);
$PacksArray[2]{$Del}{$z}{$y} = get_param("PackCDelivery".$z.$y);

$PacksArray[3]{$i}{$z}{$y} = get_param("Singles1".$i.$z.$y);
$PacksArray[3]{$Qty}{$z}{$y} = get_param("Singles1Qty".$z.$y);
$PacksArray[3]{$Tot}{$z}{$y} = get_param("Singles1Total".$z.$y);
$PacksArray[3]{$Del}{$z}{$y} = get_param("Singles1Delivery".$z.$y);

$PacksArray[4]{$i}{$z}{$y} = get_param("Singles2".$i.$z.$y);
$PacksArray[4]{$Qty}{$z}{$y} = get_param("Singles2Qty".$z.$y);
$PacksArray[4]{$Tot}{$z}{$y} = get_param("Singles2Total".$z.$y);
$PacksArray[4]{$Del}{$z}{$y} = get_param("Singles2Delivery".$z.$y);

$PacksArray[5]{$i}{$z}{$y} = get_param("Singles3".$i.$z.$y);
$PacksArray[5]{$Qty}{$z}{$y} = get_param("Singles3Qty".$z.$y);
$PacksArray[5]{$Tot}{$z}{$y} = get_param("Singles3Total".$z.$y);
$PacksArray[5]{$Del}{$z}{$y} = get_param("Singles3Delivery".$z.$y);
}
} //Comment Out
} //Comment Out



   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.