hi
i have the following problem:
i am working with jpgraph library and i use mostly pie graphs
the way i use them is calling them in IMG tags , like this
<img src='graph1.php'>
in graph1.php, i make a query to database in order to obtain results for displaying in the graphic
if my query returns no rows , i show an empty graphic with text "NO INFORMATION FOR YOUR SEARCH"
the problem is when i display 5 or 6 graphics in the same page, if any of them return information, i see 5 graphics with text
"NO INFORMATION FOR YOUR SEARCH", i don´t want this display
what i was researching is a way to load the graphics first and keep them in a php var, if it´s posible
i hope you understand my question
and if there is a fast or better way to work with this kind of graphics, i hope any advice
i´d appreciate any help
pre load images created with jpgraph
Moderator: General Moderators
-
orlandinho
- Forum Newbie
- Posts: 18
- Joined: Mon Feb 12, 2007 9:50 pm
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
-
orlandinho
- Forum Newbie
- Posts: 18
- Joined: Mon Feb 12, 2007 9:50 pm
i have a main page where i have to display some graphics , in this page i call the graphics in this way:
<img src='graph1.php' width='400' height='200'>
inside graph1.php i make a query to database and with the results i display a pie graph
i use jpgraph library for this
i also check if my query returns rows, if it doesn´t, i display an image with the text "NO INFORMATION.."
what i want to do is call graph1.php before displaying it in IMG tags and save it in a php variable
so i can check if it brings no information before showing graphics
:O
<img src='graph1.php' width='400' height='200'>
inside graph1.php i make a query to database and with the results i display a pie graph
i use jpgraph library for this
i also check if my query returns rows, if it doesn´t, i display an image with the text "NO INFORMATION.."
what i want to do is call graph1.php before displaying it in IMG tags and save it in a php variable
so i can check if it brings no information before showing graphics
:O
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
you could record the file size of the "NO INFORMATION.." graphic and test that way, not bothering to display the <img/> tag if it matches. Graph caching might be a nice feature at that point though, since you'll essentially be creating the image twice.
For that matter, why not just test for the existence of your graph data rows before adding the <img/> element?
For that matter, why not just test for the existence of your graph data rows before adding the <img/> element?
-
orlandinho
- Forum Newbie
- Posts: 18
- Joined: Mon Feb 12, 2007 9:50 pm
when i display the image in <img src='graph1.php'> i can´t check the size of the image before displaying it
i used the cache and it worked well, sadly i´am not allowed to use caching in the production server
the reason why i don´t check if there is no rows before displaying the graphic is because i directly call the graphic, which i prepare in graph1.php,
it brings me a graphic as a result of calling it
all my query is made in this graph1.php
a solution is to make the graphic querys before displaying, but i would be making the quey twice
i used the cache and it worked well, sadly i´am not allowed to use caching in the production server
the reason why i don´t check if there is no rows before displaying the graphic is because i directly call the graphic, which i prepare in graph1.php,
it brings me a graphic as a result of calling it
all my query is made in this graph1.php
a solution is to make the graphic querys before displaying, but i would be making the quey twice
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Why not have the queries run in a Model somewhere else? graph1.php is the View which uses that Model. All you need to do is ask the Model (the script which runs the queries) if there's any data and if there's not, just output an empty JPEG.orlandinho wrote:the reason why i don´t check if there is no rows before displaying the graphic is because i directly call the graphic, which i prepare in graph1.php,
it brings me a graphic as a result of calling it
all my query is made in this graph1.php