Re: ATTN: Leon Atkinson (aka: generating a graph in the middle of a page?)
| From: | Matthew Kendall | Date: | Thu, 17 Aug 2000 03:42:59 +0000 |
| Subject: | Re: ATTN: Leon Atkinson (aka: generating a graph in the middle of a page?) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12142@lists.php.net to get a copy of this message | ||
"Daevid Vincent" <DayWalker@TheMatrix.com> wrote...
> ...how can I "embed" the graph into an
> existing PHP page...
If you display data in an HTML table you can use one script that both
generates the page and the table of data in the middle of it, which sounds
like what you are doing now. However, if you want the data displayed as an
image, you need two scripts; one to generate the page and one to generate
the image.
The page script generates HTML as normal:
<html>
<head> ... </head>
<body>
<p>Here is the data you want:</p>
<img src="graph.php?dataset=sales&year=1967">
</body>
Then, instead of having a fixed image of a graph as a gif or whatever, you
have a script that generates a gif. In this example, graph.php reads the
variables passed in the URL to decide what graph is required, generates it,
then serves it back to the browser with the correct header. It is in this
script that you need the header("Content-type: image/gif"); instruction.
Of course, if all the content on the page apart from the graph is static you
do not need to generate it with a script; the script that generates the
graph is the only one you need.