How to display PHP-generated Google Chart in an HTML page
I have a file named graph.php
on my server that reads dy开发者_JAVA技巧namic content from a text file and displays a graph using Google Charts.
I also have a graph.html
file on the server, which needs to embed this graph. How do I achieve this? I tried using javascript but it didn't work, I may be wrong:
<script language="JavaScript" type="text/javascript"
src="http://mydomain/graph.php">
</script>
EDIT: Accepted answer:
Use an iframe: <iframe src="http://mydomain/graph.php" />
Other method: if the graph file is just an image, then just:
<img src="http://mydomain/graph.php" />
Make sure your headers are set correctly in that script, namely the Content-type
header (which should be image/png
), before any image data is printed.
Or, if the graph.php
file has an <img>
tag with the graph in it, just use: <? include('graph.php') ?>
.
精彩评论