Jump to content

Recommended Posts

Ok, I have a form which sends to a PHP script--that's all set and working (thanks to the help of forum members here! ;D).  Now, I'm wondering on my PHP page, if I would be able to plot, kind of like a graph, onto an image.

 

Here's what I'm thinking.

 

I already have the code all setup with the image "echoed in" successfully, and I have two numerical values based on calculation on the form (which is done).

 

My image looks like a graph, with an ongoing scale, in the shape of a diamond.  (One scale running along the bottom to the left, and one from the bottom--to the right). Is there a way, based on the numerical result, for example, my two variables are $soc and $ec - could the script place them on the graph/image according to the scale?

 

This might have been a bit confusing, so if you think this is possible, or if you need more input, just ask me.  So any help would certainly be extremely appreciated.

Thanks in advance! :)

Link to comment
https://forums.phpfreaks.com/topic/113474-php-script-to-plot-on-an-image/
Share on other sites

Ok, thanks for the response.

 

I attached an example of my "diamond".  As you see there are two scales there on the bottom of the sides.  I have two variables to match the scales in my script.  Would I be able to take my first variable, $soc for the Social scale and $ec for the Economic scale and make one point where they meet on the image here?

 

[attachment deleted by admin]

Yes, you need to do something special.  You need make a new file.  Name it diamonddraw.php.  Then do:

 

<img src="diamonddraw.php?soc=$soc&eco=$eco">

 

Then in diamonddraw.php, take those two variables from GET and use it to create the image and send the appropriate headers.

Thanks for the help, but I couldn't go about doing the GD thing.  So I made my own image files.  It took a while (121 of them), but they are done.  Is there a way, though, to take one of my numerical variables in the PHP script and say, for example (since there are two variables on this graph)

 

if $soc = 40 and $ec = 60 - show image diamond_s40e60.jpg

 

I realize that wasn't in a PHP script format, but that's because I'm not sure how I would include that with both.

 

Also, my numerical values will not be exactly, let's use the example--40 soc---it might be: soc = 37, ec = 55.

 

Any ideas how to script that?

 

Thanks!

Thanks!  I think its getting closer... but when the result is, for example for image diamond_s20e90.jpg - it will go to diamond_s-20e90.jpg

 

But all of the files are saved as diamond_s#e#.jpg like above--but no hyphens like in the second image name.

 

Again, thank you for helping!

It's probably because I changed one part, my fault for not mentioning it, I forgot.

 

My points are based on 20, so I have another variable for $soc and $ec to multiply by 5 to get the percentage to plot on the map.

 

That variable is just $soc_per and $ec_per

 

printf('<img src="diamond_s%de%d.jpg" />', round($soc_per, -1), round($ec_per, -1));

 

But I think that's where it went wrong with the hyphens added in.

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.