Jump to content


Photo

Adding variables


  • Please log in to reply
4 replies to this topic

#1 Prank

Prank
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSydney, AUS

Posted 14 April 2006 - 02:46 AM

Hi Guys,

I am a bit unsure of how to do this, I'd appreciate any help.

What I am trying to do is add up a total number as reported by variables, but the problem is that its the same variable..

For eg;
while {

$total = 3;

}

How would I add all the $total's for each instance that the 'while' was run?

I hope this makes sense and I am assuming it is an easy answer..

Thanks in advance,

Christian
The way to a mans stomach is through his heart.

#2 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 14 April 2006 - 03:33 AM

well, you could just do something like this. You do need a condition in your while statment though....

$count=0;
while ( /*some condition*/ ){

$total = 3;
$count++;
}



#3 Prank

Prank
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSydney, AUS

Posted 14 April 2006 - 03:39 AM

So that would just add a 1 to the variable $count each time its run?

Heres my actual code; [a href=\"http://pastebin.com/658997\" target=\"_blank\"]http://pastebin.com/658997[/a]

I need to grab the total value of $total and $qty

Thanks for your help.
The way to a mans stomach is through his heart.

#4 Prank

Prank
  • Members
  • PipPip
  • Member
  • 25 posts
  • LocationSydney, AUS

Posted 14 April 2006 - 04:14 AM

nm, i figured it out.. stupidly simple.
The way to a mans stomach is through his heart.

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 14 April 2006 - 04:50 AM

Can you post the solution to your problem, so other people can learn from your experience?

BTW, I took a look at your code. Do you realize your creating one form each time you go through the 'while' loop?

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users