html - using a php file as a img src

505

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

667

Answer

Solution:

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

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

People are also looking for solutions to the problem: php - the eclipse display an error in the InBackground method i do not know how to fix it

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.