Jump to content

Passing variables to external JPGraph script


BladeMetal

Recommended Posts

Due to my website containing both images and text, I was forced to implement JPGraph using <img src="myscript.php"> However, my only issue is that I can't send values to it. The graph shows the average age of a football team over time and dynamically updates using a MySQL database. However, the graph is to used for many different football teams and I thought I could just use:
[code]
mysql_query("SELECT * FROM graph_data WHERE team_id=$team_id");
[/code]
Because my script is external, is there anyway to get the $team_id variable from index.php into the external script (myscript.php)? If it can, then all my issues will be solved. Thanks in advance.
-Adam
Link to comment
Share on other sites

you can:
1. set the variable into a global cookie or session
2. probably a little easier, use include("filename.php") //replace filename with whatever file has the variable you want and it will inherit the variable value/name
Link to comment
Share on other sites

include won't work, it just generates an image not found symbol (the red x symbol). Also, sessions didn't work either. I tested with sessions while using include() and it found the variable and printed it for me(obviously, because it was also is the right scope, namely integrated to index.php). However, it doesn't seem to recognise it in a straight <img> tag. Trying cookies now.

ok, it worked with cookies. Thanks for your help.
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.

Guest
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.