Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-13 Thread Jason Pruim

Hi Everyone,

I am taking another stab at this problem, complete with code and an  
example...


Here is the issue:

I need to be able to display pounds and ounces of a given number of  
pieces, the code I have does this just fine for a single route... But  
what I can't seem to get through my head is how to do it for a  
variable number of routes?


Here is the code I'm working with...


Weight calculator

		Weight of a single piece:size="5" value="{$PieceWeight}">


HTML;

while ($c != $num) {
echo <<			Route Number:value="{$RouteNumber}"> Number of pieces: name="txtRoutePieces" value="{$RoutePieces}"size="5">Total  
weight of route: {$weightExplode[0]}# {$explodeOunces} Ounceslabel>

HTML;




$c++;

}
echo "";
//DEBUG 
dump_debug($RoutePieces);
dump_debug($RouteNumber);
dump_debug($_POST);
print_debug($explodeOunces);
dump_debug($weightExplode);
//END DEBUG


}else{
echo "";
echo "Number of routes: 
";
echo "";
}



?>

The website is: HTTP://www.raoset.com/dev/weightcalc/

I need help! My brain is going to die tonight without it :)




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Roberto Mansfield
Jason Pruim wrote:
>> Why do you want tenth's of pounds? Just divide pounds by 16 and you'll
>> get ounces.
> 
> It's actually for a weight calculator that we use for some of our
> mailings. when you take .226 and multiply that by 464 you get 104.864
> ounces.
> 
> I need to be able to display that as: 6 # 13.824 Ounces.

Then I think you want to use the mod operator:

(I'm assuming .226 is the cost per ounce and 464 is the total number of
ounces)

$pounds = intval( .226 * 464 / 16 );
$ounces = ( .226 * 464 ) % 16;


Roberto

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread tedd

At 1:29 PM -0400 5/9/08, Jason Pruim wrote:

Hey tedd

On May 9, 2008, at 1:21 PM, tedd wrote:


At 12:56 PM -0400 5/9/08, Jason Pruim wrote:

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.


What??

Why do you want tenth's of pounds? Just divide pounds by 16 and 
you'll get ounces.


It's actually for a weight calculator that we use for some of our 
mailings. when you take .226 and multiply that by 464 you get 
104.864 ounces.


I need to be able to display that as: 6 # 13.824 Ounces.


Well, that explains it. Now, it's Friday for me.

You know, if you take the total weight and divide that by the number 
of gorillas per lamp-pole you'll go back in time. I'm totally lost.


Sorry I couldn't be more help.

Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Jason Pruim

Hey tedd


On May 9, 2008, at 1:21 PM, tedd wrote:


At 12:56 PM -0400 5/9/08, Jason Pruim wrote:

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.


What??

Why do you want tenth's of pounds? Just divide pounds by 16 and  
you'll get ounces.


It's actually for a weight calculator that we use for some of our  
mailings. when you take .226 and multiply that by 464 you get 104.864  
ounces.


I need to be able to display that as: 6 # 13.824 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...


How much does each box weight and how many boxes? That's all you need.


the routes can have anywhere from 1 piece to 800+ pieces.  and we can  
have as few as 1 route to as many as 50 or 60+






---

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.


Is $PieceWeight is a static number?

The last time I checked, the cost per oz for shipping depends upon  
the weight. The more weight, the less the cost per ounce. Is that  
not true?


Normally yes, but not in this case :) I'm using it so I don't have to  
sit there and count out 464 postcards. I can just throw them on my  
scale and get the total weight.





---

As for the code, that's pretty simple.


Then it's a simple "It's a friday thing" for me... My wife keeps  
rubbing in that today is her last day of work until mid august... :P



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Jason Pruim


On May 9, 2008, at 1:05 PM, Dan Joseph wrote:

On Fri, May 9, 2008 at 12:56 PM, Jason Pruim <[EMAIL PROTECTED]>  
wrote:



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:

  Route Number:value

="{$RouteNumber[$i]}"> Number of pieces: name="txtRoutePieces[$i]" size="4"  
value="{$RoutePieces[$i]}">Total
weight of route: {$weightExplode[0]} # {$explodeOunces} Ounceslabel>

  


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
[EMAIL PROTECTED]





Rather than a counter, you could use foreach:

foreach ( $RoutePieces as $key => $value )
{
$blah = $value * $PieceWeight;
}

Make sense?


The idea make sense, and I think it will work. But I'm getting this  
error:


[Fri May  9 13:19:33 2008] [error] PHP Fatal error:  Unsupported  
operand types in /Volumes/RAIDer/webserver/Documents/dev/weightcalc/ 
index.php on line 22



foreach ($RoutePieces as $key => $value){
$testWeight = $value * $PieceWeight; <---Line 22
}

Some quick trying tells me that the problem is my "*" I don't remember  
having this problem before. Is there another character I should use to  
multiply with? :)


Thanks for looking!



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424-9337
www.raoset.com
[EMAIL PROTECTED]




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread tedd

At 12:56 PM -0400 5/9/08, Jason Pruim wrote:

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.


What??

Why do you want tenth's of pounds? Just divide pounds by 16 and 
you'll get 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...


How much does each box weight and how many boxes? That's all you need.

---

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.


Is $PieceWeight is a static number?

The last time I checked, the cost per oz for shipping depends upon 
the weight. The more weight, the less the cost per ounce. Is that not 
true?


---

As for the code, that's pretty simple.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Why doesn't working with array's ever stick in my thick head?

2008-05-09 Thread Dan Joseph
On Fri, May 9, 2008 at 12:56 PM, Jason Pruim <[EMAIL PROTECTED]> wrote:

> 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:
> $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 <<
>
>Route Number: ="{$RouteNumber[$i]}"> Number of pieces:  name="txtRoutePieces[$i]" size="4" value="{$RoutePieces[$i]}">Total
> weight of route: {$weightExplode[0]} # {$explodeOunces} Ounces
>
>
>
> 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
> [EMAIL PROTECTED]
>
>
>
>
Rather than a counter, you could use foreach:

foreach ( $RoutePieces as $key => $value )
{
 $blah = $value * $PieceWeight;
}

Make sense?

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month. Reseller plans and
Dedicated servers available.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


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

2008-05-09 Thread Jason Pruim

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:


	Route Number:="{$RouteNumber[$i]}"> Number of pieces: name="txtRoutePieces[$i]" size="4"  
value="{$RoutePieces[$i]}">Total weight of route:  
{$weightExplode[0]} # {$explodeOunces} Ounces




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
[EMAIL PROTECTED]