tags:

views:

72

answers:

5

Hi,

I have 3 php files; pie.php, bar.php and line.php. These when run individually give output as a webpage. If all are run, 3 separate webpages open up displaying a pie chart, bar chart and line graph.

What i want to do is to divide a single webpage into three part and show each individual php file's result (i.e. the graphs) in one of the three parts.

  1. Is it possible to do it?
  2. Would i need some hack for php or should i turn to java script
  3. Any example that you know giving the same
A: 

You could include all three of the PHP scripts together on a single page using either the include or require methods.

<?php
include('path/to/fileOne.php');
include('path/to/fileTwo.php');
include('path/to/fileThree.php');
?>
Secret Agent Man
A: 

Are you able to change the files? If so, strip out the bulk of the HTML that produces the primary document structure and then just include them at the point you want their output displayed.

I can't really get more specific without knowing what those scripts have in them and what sort of arguments they expect.

John Cavan
Thank a lot for your quick reply. I actually wanted to have a functionality like http://amcharts.com/ has i.e. showing different graphs. I think your idea will work out for me to get the same functionality.
+1  A: 

If you have access to the source then I suggest you split it up like this:

  • bar.php: bar chart without header/footer;
  • line.php: line chart without header/footer;
  • pie.php: pie chart without header/footer;
  • header.php: header;
  • footer.php: footer.

and then create your pages:

  • piepage.php: include header.php, pie.php, footer.php;
  • linepage.php: include header.php, line.php, footer.php;
  • barpage.php: include header.php, bar.php, footer.php;
  • all.php: include header.php, pie.php, line.php, bar.php, footer.php.
cletus
A: 

You could also have a master page that puts each of those pages in an iframe.

<html>
<head>
...
</head>
<body>
...
<div>
<iframe src="pie.php" width="33%" height="200px"></iframe>
<iframe src="bar.php" width="33%" height="200px"></iframe>
<iframe src="line.php" width="33%" height="200px"></iframe>
</div>
...
</body>
</html>

Of course I wouldn't recommend doing it this way if you can avoid it. Frames aren't user friendly or search engine friendly.

Kip
A: