PhilPearson Posted April 2, 2011 Share Posted April 2, 2011 OK, hello everyone from your newest newbie - to this forum anyway. First thing to say is I do not claim to be the best php coder there is - as you will see when you look at my code ! Secondly, I have scoured/googled many sources to try and understand an answer to my problem without success. So, please first look at this page - http://www.thepearsons-ws.co.uk/php/MetMonthly.php If you pick March 2011 say you see a list of data presented on the same page. This is the effect I want to get to with a GD graph. If you now try my first attempt - http://www.thepearsons-ws.co.uk/php/raingraph3monthlyselect.php - and pick March 2011 and Submit AND click the link you get a graph on a new page. OK, but now what I want - I want the image on that same first page. So, I have the attached code which produces this - http://www.thepearsons-ws.co.uk/php/raingraph3monthlyselect2.php I have hacked the code around a bit but basically it's - PHP - form and data selection HTML - form with pull downs PHP - display graph. The image is broken. If I remove the HTML block completely it produces output but of course I can not vary the selection. Any small element of HTML here destroys the image - no whitespace or such - just <html> is enough. So, any clues on how to correctly structure this code would be greatly appreciated. Regards Phil [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Jnerocorp Posted April 2, 2011 Share Posted April 2, 2011 the easiest way to do it i guess is to use an iframe <iframe src="http://www.thepearsons-ws.co.uk/php/raingraph3monthly.php?period=<?php echo $_GET['period']; ?>" width="100%" height="100%"> <p>Your browser does not support iframes.</p> </iframe> place this code on the page where the user selects a date and clicks submit then when they submit make it goto the same page with "?period=######" at the end of course the #'s would be where the e.g 201101 would go Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 2, 2011 Share Posted April 2, 2011 This is not a php problem. It seems you misunderstand some of the basics of html. When you have an html page, I'm sure you know that when you want to include an image, that requires a tag. You can not just spit out image data in the middle of html and expect that to work. You were on the right track initially when you developed a script that accepts parameters and returns an image. To include that on a page simply requires that you reference your image script inside an tag. All that you really require with the form is to have the period parameter filled in in your serverside code by getting the appropriate $_POST[] variables and adding them to the url. Quote Link to comment Share on other sites More sharing options...
PhilPearson Posted April 2, 2011 Author Share Posted April 2, 2011 Thanks for your replies David and Jnerocorp. David - your "fix" works just fine - of course ! I'd gotten into the position of fixing some other issues and in the process dug myself into a whole I couldn't see the way out of. Many thanks. Phil Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 2, 2011 Share Posted April 2, 2011 No worries, it happens to all of us at some point that we miss the forest for the trees. The important thing is that you got the more complicated things sorted out, and were able to get the graph and data generated in the first place. Quote Link to comment Share on other sites More sharing options...
PhilPearson Posted April 2, 2011 Author Share Posted April 2, 2011 Hmm. Sometimes that forest can become very thick. Anyway - http://www.thepearsons-ws.co.uk/php/raingraph3monthlyselect.php - looks a lot better now - apart from the cosmetics of titles and such. Phil 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.