|
Posted by Paul Charlton-Thomson on 06/28/05 21:19
Ken,
Yes you are right. Sorry ... I have two versions one with $_POST and one
with $_GET commands.
The one I posted was $_POST and should have been $_GET which still does not
work.
All I see is a red cross i.e. image missing.
Paul.
So here's the correct PHP code ...
<?php
$segment_size[0] = $_GET['a'];
$segment_size[1] = $_GET['b'];
$segment_size[2] = $_GET['c'];
$segment_size[3] = $_GET['d'];
$segment_size[4] = $_GET['e'];
$segment_size[5] = $_GET['f'];
$segment_size[6] = $_GET['g'];
$segment_size[7] = $_GET['h'];
$width = 300;
$height = 200;
$image = imageCreate($width, $height);
$background = imageColorAllocate($image, 255, 255, 255);
$segment_colour[0] = imageColorAllocate($image, 255, 203, 3);
$segment_colour[1] = imageColorAllocate($image, 220, 101, 29);
$segment_colour[2] = imageColorAllocate($image, 189, 24, 51);
$segment_colour[3] = imageColorAllocate($image, 214, 0, 127);
$segment_colour[4] = imageColorAllocate($image, 98, 1, 96);
$segment_colour[5] = imageColorAllocate($image, 0, 62, 136);
$segment_colour[6] = imageColorAllocate($image, 0, 102, 179);
$segment_colour[7] = imageColorAllocate($image, 0, 145, 195);
$cien[0] = imagecolorallocate($image, 205, 153, 0);
$cien[1] = imagecolorallocate($image, 170, 51, 0);
$cien[2] = imagecolorallocate($image, 139, 0, 1);
$cien[3] = imagecolorallocate($image, 164, 0, 77);
$cien[4] = imagecolorallocate($image, 48, 0, 46);
$cien[5] = imagecolorallocate($image, 0, 12, 86);
$cien[6] = imagecolorallocate($image, 0, 52, 129);
$cien[7] = imagecolorallocate($image, 0, 95, 145);
$cien[8] = imagecolorallocate($image, 0, 65, 56);
$suma = array_sum($segment_size);
$stopnie = 0;
for($i = 0; $i < count($segment_size); $i++){
$start[$i]= $stopnie;
$stop[$i] = $stopnie + round(($segment_size[$i] / $suma) * 360, 0);
$stopnie = $stop[$i];
}
$x = $width / 2;
$size = $width / 7;
$y = $height / 2 - $size / 2 - 1;
for($g = $size; $g > 0; $g--){
for($n = 0; $n < count($segment_size); $n++){
imagefilledarc($image, $x, $y+$g, $width, $height - $size,
$start[$n], $stop[$n], $cien[$n], IMG_ARC_PIE);
}
}
for($i = 0; $i < count($segment_size); $i++){
imagefilledarc($image, $x, $y, $width, $height - $size, $start[$i],
$stop[$i], $segment_colour[$i], IMG_ARC_PIE);
}
header("Content-type: image/png");
imagePNG($image);
imageDestroy($image);
?>
"Ken Robinson" <kenrbnsn@rbnsn.com> wrote in message
news:1119981346.078370.94460@g47g2000cwa.googlegroups.com...
>
>
> Paul Charlton-Thomson wrote (in part):
> > Here's the draw_pie.php code ...
> >
> > <?php
> > $segment_size[0] = $_POST['a'];
> > $segment_size[1] = $_POST['b'];
> > $segment_size[2] = $_POST['c'];
> > $segment_size[3] = $_POST['d'];
> > $segment_size[4] = $_POST['e'];
> > $segment_size[5] = $_POST['f'];
> > $segment_size[6] = $_POST['g'];
> > $segment_size[7] = $_POST['h'];
>
> You're invoking this script with
>
>
SRC="draw_pie.php?a='.$a.'&b='.$b.'&c='.$c.'&d='.$d.'&e='.$e.'&f='.$f.'&g='.
> $g.'&h='.$h.'" WIDTH="300" HEIGHT="200">
>
> Yet you're looking for the parameters in the POST superarray. That will
> not work. Use the $_GET superarray (replace $_POST with $_GET) and try
> again.
>
> Ken
>
Navigation:
[Reply to this message]
|