jay83r Posted December 14, 2011 Share Posted December 14, 2011 does anyone know how to do an if statement in the middle of a gd image so that if a dropdown box is selected it draws different lines... <label for="height"></label> <select name="height" id="height"> <option value="2.4">2.4</option> <option value="2.7">2.7</option> </select> </form> <?php require_once('./include/connection.php'); ?> <?php header ("Content-type: image/png"); ?> <?php $x1=$_GET['x1']; $x2=$_GET['x2']; $y1=$_GET['y1']; $y2=$_GET['y2']; $im = @ImageCreate (800, 600) or die ("Cannot Initialize new GD image stream"); $background_color = ImageColorAllocate ($im, 255, 255, 255); $line_color = ImageColorAllocate ($im, 0, 0, 0); // imageline ($im,$x1,$y1,$x2,$y2,$text_color); //front base line if "height" = "2.4" imageline ($im,50,550,500,550,$line_color); else imageline ($im,50,200,500,200,$line_color); endif //front left vertical imageline ($im,50,550,50,200,$line_color); //front right vertical imageline ($im,500,550,500,200,$line_color); //bottom of apex imageline ($im,50,200,500,200,$line_color); //left roof line imageline ($im,50,200,275,100,$line_color); //right roof line imageline ($im,500,200,275,100,$line_color); ImagePng ($im); ?> Quote Link to comment https://forums.phpfreaks.com/topic/253135-how-to-do-an-if-statement-in-gd-image/ Share on other sites More sharing options...
SergeiSS Posted December 14, 2011 Share Posted December 14, 2011 This code header ("Content-type: image/png"); MUST be the first output of this script! If you like to make a selection, do it in a HTML page but not inside GD script. Then send this selection into you GD script using GET parameter(s). For example, you may do it with help of JavaScript. Just for example: let pict.php is you GD script. Use JS, change id value to whatever you wish (set new SRC for tag IMG). Browser will request your script with a new parameter <img src="pict.php?id=25" /> Quote Link to comment https://forums.phpfreaks.com/topic/253135-how-to-do-an-if-statement-in-gd-image/#findComment-1297796 Share on other sites More sharing options...
jay83r Posted December 14, 2011 Author Share Posted December 14, 2011 how do i call the co-ordinates of the line from a mysql database, i want to give each line a meaniful name and then just call it to display it. Quote Link to comment https://forums.phpfreaks.com/topic/253135-how-to-do-an-if-statement-in-gd-image/#findComment-1297967 Share on other sites More sharing options...
SergeiSS Posted December 15, 2011 Share Posted December 15, 2011 And where do you see a problem? First ask user and then send this info into DB. And then you can do whatever you wish. Quote Link to comment https://forums.phpfreaks.com/topic/253135-how-to-do-an-if-statement-in-gd-image/#findComment-1298207 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.