I'm sorry, my head is not with it today... What am I doing wrong here, the result I am trying to achieve: 1 80% 2 80% 3 80% etc.. 42 times. <?php for($i=1;$i<=42;$i++){ $p = array($percentage = 100 * $i = 80 / 100); foreach ($p as $percent) { echo $i, $percent,"%"; } } ?> PHP:
$i = 1-42 $percentage = 100 * $i = 80 / 100); I will populate the variable "80" from a mysql statement ..and thus whatever "80" = I will print/echo that to a page
Ok I understand the bolded text..but not the percentage - can you reply with an example, lets say if $i = 1; what do you expect $percentage to be? - if $i = 5 what would $percentage be? //Caution: im quite tired/sleepy so apologies.
<?php $p=array(); $percentage =100; for($i=1;$i<=42;$i++){ $buff= $i; $p[$i] = ($percentage * $buff = 80 / 100); } $i = 1; foreach ($p as $percent) { echo $i++.' ', $percent,"%"; echo "<br/>"; } ?> Code (markup):
Its a percentage thing. If you echo $percentage = 100 * 1 = 50 / 100); or $percentage = 100 * 2 = 50 / 100); up to 42 you will get 1 80% , 2 80% etc.. Which is why I tried the ++, instead of writing out 42 equations