Jump to content

Possible to stop ‘including’?


Recommended Posts

Hi all,


So I have a page which uses mysql_query to select some variables from a table, and then produces an array in order to plot this information on a graph (data used for this depends on the unique id which is obtained by $_GET [‘mrn’]. This is all working fine. However, what I want to do now is include multiple copies of these graphs on a single page  (graphs for different mrn’s). I tried to do this by including the files like this:

<php $_GET[mrn] = "1";
include('graph.php'); ?>

//some html

<php $_GET[mrn] = "2";
include('graph.php'); ?>

The problem with this method has been that although it works once, the second you include a second graph it stops working (presumably because I have tried to assign two different values to the same variable by effectively defining it twice?)


My question is therefore, is there some way to include a file, get its output (draw its graph), and then stop including it, so that I can start including the next file (drawing next graph). My reading so far has led me to believe there probably isn’t a way? Am I correct about that? Does anyone have any ideas about how I might get this working using a different technique?


Thanks in advance for any help,



Link to comment
Share on other sites

it all depends on what the code in graph.php is doing.


if graph.php is dynamically producing an image, you must use an <img src=' ... '> tag for each image you put onto a web page and since graph.php apparently expects a get parameter, you would do something like - <img src='graph.php?mrn=1'>   <img src='graph.php?mrn=2'>

Link to comment
Share on other sites

I would agree to what mac_gyver said. Instead of including graph.php, just make a header call for it so that it's marked as an image file and not a PHP file, and use the <img> HTML tag to show it. Although your current method shouldn't be making problems IF the function of graph.php is to produce a graph and once the graph is echoed, it should die.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.