Jump to content


Photo

Passing variables to external JPGraph script


  • Please log in to reply
2 replies to this topic

#1 BladeMetal

BladeMetal
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 April 2006 - 12:56 AM

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:
mysql_query("SELECT * FROM graph_data WHERE team_id=$team_id"); 
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

#2 Doqrs

Doqrs
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 21 April 2006 - 01:01 AM

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

#3 BladeMetal

BladeMetal
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 April 2006 - 01:27 AM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users