Replacing code based on static variables to variable variables.

This is a discussion on Replacing code based on static variables to variable variables. within the PHP Language forums, part of the PHP Programming Forums category; Can anyone give me some help or tips in converting this code to take 2 variables that will specify the ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-06-2003
David
 
Posts: n/a
Default Replacing code based on static variables to variable variables.

Can anyone give me some help or tips in converting this code to take 2 variables that will specify the number of Pack
type lines and the number of Single type lines. We use it to create a web page that allows us to split a garment
delivery over multiple dates and and to specify the number and size of garments in a pack and the number and size of
individual garments in the delivery. 3 of each has been enough until now. However we are finding new customers that want
it spread over as many as 5 to 8 of each type pack and single.

Everything is stored in an array $RPack.
Easy to do as i new there were only ever goung to be 6 lines.

$maxC is the number of colours available (usually 3)
$maxR is the number of lengths each colour is available (usually 3)
$maxH is the number of sizes each length is available in. (Between 8 & 14)

Input() is a function for drawing HTML input boxes of the format

Input (Size,Value,Class,Name,Maxlength,Readonly)

I think what I need is to use variable variables but I am having a hard time getting my head around it so any tips and
advice would be very gratefully received.

// Create Data Entry, Boxes for Amt,Qty Total and Date
for ($z=0; $z<$maxC; $z++){
for ($y=0; $y<$maxR; $y++){
//Set Temp variables to 0 or ""
$ThisColour = "";
$ThisRange = "";
$ColourSize="";
$P_In0="";
$P_In1="";
$P_In2="";
$S_In0="";
$S_In1="";
$S_In2="";
$Total_In="";
$RatioTotal_In="";
$LineAmt0 = 0;
$LineAmt1 = 0;
$LineAmt2 = 0;
$LineAmtS0 = 0;
$LineAmtS1 = 0;
$LineAmtS2 = 0;
$ColourSize = Input(8,$RatioColours{$z}.' '.$RatioRange{$y};,formstyle,Colour_Size,10);

for ($i=0; $i<$maxH; $i++){
// Check already an entry if so use it, if not add default order line to singles1 and set rest to 0
if($fldfldMDA==1){

$Pack0 = Input(3,$RPack[0]{$i}{$z}{$y},formstyle,Pack0.$i.$z.$y,10);
$LineAmt0 = $LineAmt0 + $RPack[0]{$i}{$z}{$y};
$ColSumP0{$i}{$z}{$y} = ($RPack[0]{$i}{$z}{$y}*$RPack[0]{$Qty}{$z}{$y});

$Pack1 = Input(3,$RPack[1]{$i}{$z}{$y},formstyle,Pack1.$i.$z.$y,10);
$LineAmt1 = $LineAmt1 + $RPack[1]{$i}{$z}{$y};
$ColSumP1{$i}{$z}{$y} = ($RPack[1]{$i}{$z}{$y}*$RPack[1]{$Qty}{$z}{$y});

$Pack2 = Input(3,$RPack[2]{$i}{$z}{$y},formstyle,Pack2.$i.$z.$y,10);
$LineAmt2 = $LineAmt2 + $RPack[2]{$i}{$z}{$y};
$ColSumP2{$i}{$z}{$y} = ($RPack[2]{$i}{$z}{$y}*$RPack[2]{$Qty}{$z}{$y});

$Singles0 = Input(3,$RPack[3]{$i}{$z}{$y},formstyle,Singles0.$i.$z.$y,10);
$LineAmtS0 = $LineAmtS0 + $RPack[3]{$i}{$z}{$y};
$ColSumS0{$i}{$z}{$y} = ($RPack[3]{$i}{$z}{$y}*$RPack[3]{$Qty}{$z}{$y});

$Singles1 = Input(3,$RPack[4]{$i}{$z}{$y},formstyle,Singles1.$i.$z.$y,10);
$LineAmtS1 = $LineAmtS1 + $RPack[4]{$i}{$z}{$y};
$ColSumS1{$i}{$z}{$y} = ($RPack[4]{$i}{$z}{$y}*$RPack[4]{$Qty}{$z}{$y});

$Singles2 = Input(3,$RPack[5]{$i}{$z}{$y},formstyle,Singles2.$i.$z.$y,10);
$LineAmtS2 = $LineAmtS2 + $RPack[5]{$i}{$z}{$y};
$ColSumS2{$i}{$z}{$y} = ($RPack[5]{$i}{$z}{$y}*$RPack[5]{$Qty}{$z}{$y});

$ColTotal =
$ColSumP0{$i}{$z}{$y}+$ColSumP1{$i}{$z}{$y}+$ColSu mP2{$i}{$z}{$y}+$ColSumS0{$i}{$z}{$y}+$ColSumS1{$i }{$z}{$y}+$ColSumS2{
$i}{$z}{$y};

$RatioTotal = Input(3,$ColTotal,formstyle,ColTotal.$i.$z.$y,10);

$Total = Input(3,$RatioAmt{$i}{$z}{$y},formstyle,Total.$i.$ z.$y,10);

}
else{
$Pack0 = Input(3,0,formstyle,Pack0.$i.$z.$y,10);
$Pack1 = Input(3,0,formstyle,Pack1.$i.$z.$y,10);
$Pack2 = Input(3,0,formstyle,Pack2.$i.$z.$y,10);
$Singles0 = Input(3,$RatioAmt{$i}{$z}{$y},formstyle,Singles0.$ i.$z.$y,10);
$Singles1 = Input(3,0,formstyle,Singles1.$i.$z.$y,10);
$Singles2 = Input(3,0,formstyle,Singles2.$i.$z.$y,10);
$Total = Input(3,$RatioAmt{$i}{$z}{$y},formstyle,Total.$i.$ z.$y,10);
$RatioTotal = Input(3,0,formstyle,ColTotal.$i.$z.$y,10);
}
//Save Input Boxes for later
$P_In0 = $P_In0.$Pack0;
$P_In1 = $P_In1.$Pack1;
$P_In2 = $P_In2.$Pack2;
$S_In0 = $S_In0.$Singles0;
$S_In1 = $S_In1.$Singles1;
$S_In2 = $S_In2.$Singles2;
$Total_In = $Total_In.$Total;
$RatioTotal_In = $RatioTotal_In.$RatioTotal;
}
$RatioPacksOrdered =
$ColourSize.'<br>'.$fldHeaderR.'<br>'.$P_In0.'<br> '.$P_In1.'<br>'.$P_In2.'<br>'.$S_In0.'<br>'.$S_In1 .'<br>'.$S_In2.'<br>
'.$RatioTotal_In.'<br>'.$Total_In.'<br>';
//Pass to display variable
$fldfldRatioPacksOrdered = $fldfldRatioPacksOrdered.$RatioPacksOrdered.'<br>' ;
}
}


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:13 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0