Why doesn't working with array's ever stick in my thick head?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Everyone,

SO it's friday, I'm tired, and I can't seem to think straight... I am attempting to do some very basic math with some arrays... Here's the pseudo code that I'm working with:

NumberOfPieces * PieceWeight = TotalWeight

explode total weight to get tenth's of pounds, then divide tenth's of pounds by 16 to grab ounces.

Display TotalWeight # Exploded Ounces.

Which I have working just fine for a single set of boxes...

My problem is I want to be able to automatically add say 50 boxes in a form to process the weight of each route...

So what I need to do is probably use some kind of a counter to loop through my $RoutePieces array and multiply by the $PieceWeight? $PieceWeight is a static number.

Now let me show you some abbreviated code to try and explain what I'm using right now:
<?PHP
	$i= "0";
	$num= "2";
	$PieceWeight = $_POST['txtPieceWeight'];
	$RoutePieces[] = $_POST['txtRoutePieces'];
	$RouteNumber[] = $_POST['txtRoute'];
	
	$totalWeight = $PieceWeight * $RoutePieces/16;
	$weightExplode = explode('.', $totalWeight);
	//$weightOunces = ((float)('.' . $weightExplode[1])) * 16;
	// Use stut's method... Seems cleaner
	$explodeOunces = ($totalWeight - intval($totalWeight)) * 16;

		while($i <= $num){
	echo <<<HTML

		<p>
Route Number:<input type="text" name="txtRoute[$i]" size="4" value ="{$RouteNumber[$i]}"> Number of pieces: <input type="text" name="txtRoutePieces[$i]" size="4" value="{$RoutePieces[$i]}"><label>Total weight of route: {$weightExplode[0]} # {$explodeOunces} Ounces</label>
	</p>

		
HTML;
			
	$i++;
	echo $i;
		}
?>

the $_POST array has the proper values stored properly... I just can't seem to figure out how to work with the values... Any ideas? Or slaps on the back of the head to wake me up a little? :)

I need help :P



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
japruim@xxxxxxxxxx




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux