mastubbs Posted June 8, 2013 Share Posted June 8, 2013 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, Matt Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted June 8, 2013 Share Posted June 8, 2013 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'> Quote Link to comment Share on other sites More sharing options...
xenLiam Posted June 8, 2013 Share Posted June 8, 2013 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.