user3524031
user3524031

Reputation: 37

using a php file as a img src

Below is the php code that makes a pie chart its saved in a php file called piechart.php

<?php

//create image
$image = imagecreatetruecolor(250,250);
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);

//allocate some colour
$white = imagecolorallocate($image, 0xFF , 0xFF, 0xFF);
$gray = imagecolorallocate($image, 0xC0 , 0xC0, 0xC0);
$darkgray = imagecolorallocate($image, 0x90 , 0x90, 0x90);
$navy = imagecolorallocate($image, 0x00 , 0x00, 0x80);
$darknavy = imagecolorallocate($image, 0x00 , 0x00, 0x05);
$red = imagecolorallocate($image, 0xFF , 0x00, 0x00);
$darkred = imagecolorallocate($image, 0x90, 0x00, 0x00);

//make the 3d effect
//for($i = 60; $i >50; $i--){
//imagefilledarc($image, 50, $i, 100, 50, 0, 180, $darknavy, IMG_ARC_PIE);
//imagefilledarc($image, 50, $i, 100, 50, 180, 360, $darkgray, IMG_ARC_PIE);
//imagefilledarc($image, 50, $i, 100, 50, 180, 360, $darkred, IMG_ARC_PIE);
//}
imagefilledarc($image ,125 ,125 , 200, 200, 0, 180, $navy, IMG_ARC_PIE);
//imagefilledarc($image ,50 ,50 , 100, 50, 180, 360, $gray, IMG_ARC_PIE);
imagefilledarc($image ,125 ,125 , 200, 200, 180, 360, $red, IMG_ARC_PIE);

//flush image
header('Content-type: image/png');
imagepng($image);
//imagedestroy($image);
?>

I want this image to be used in another webpage. I have another webpage called about us that explains what the website is all about. Heres a section of the code for that page

<h1>What is Rugby coach analysis ?</h1>
<hr />
<br />

Is there a way i can get that pie chart image to appear below the
maybe using img src? or another method?

Thanks

Upvotes: 0

Views: 892

Answers (1)

Ryan Knopp
Ryan Knopp

Reputation: 612

You mean something like this? (piechart.php would be the url to that file).

<img src="/piechart.php" alt="pie chart" />

Upvotes: 3

Related Questions