springer- Posted January 12, 2009 Share Posted January 12, 2009 First I will state that I have no clue what I am doing. I can hack around with some stuff but I have never done any PHP until now. I can make some sense out of it but not enough to follow what is going on. I have a PHP script (guess that is the correct word) that I want to customize. Right now it records a "Dot" in grid. The grid is labeled 8 through 17. There is only 1 dot and it can be placed in any of the 8 - 17 locations. My goal is to have a separate distinguishable dot for each location. For example right now it is a red dot for any of the 8 - 17 locations. I would like to the red dot had a number in it that corresponds to the location. For example, when the dot is placed in location 8, I want it to be red dot with an 8 in it. When placed in location 9, I would like it to be a red dot with a 9 in it. I can handle the simple graphics to create the dots with the numbers. Here is the portion of the script that handles the dots. for ($i = 8; $i <= 17; $i++) { if ( $datetime['hours'] == $i ) { $back[$i] = "<img src=$image_dir/$dot_image $alt>"; if ($update && $isChangeable) { $in= "<a href=\"$baseurl?in=1&userid=".$row['userid']."#".$row['userid']."\">" ."<img src=$image_dir/$empty_image BORDER=0></a>"; } else { $in= "<img src=$image_dir/$empty_image>"; } } else { if ($update && $isChangeable) { $back[$i] = "<a href=\"$baseurl?return=$i&userid=".$row['userid']."#".$row['userid']."\">" ."<img src=$image_dir/$empty_image BORDER=0></a>"; } else { $back[$i] = "<img src=$image_dir/$empty_image>"; } } } The $dot_image variable (assuming it is a variable) is the image and is defined in the script. The $i represents the 8 - 17 location. I guess the goal would be to make add them together (??) $dot_image + $i. I can define 10 different images, assume $dot_image8, $dot_image9, etc. My question is can this be done? Is more info needed? Any help is greatly appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/140561-solved-need-help-with-variable-image-name/ Share on other sites More sharing options...
springer- Posted January 13, 2009 Author Share Posted January 13, 2009 So no one has a clue? Was it that tough a question? I guess i'll go back to my motorcycle forum and ask there. I just thought maybe a PHP forum was a better place to ask, who knew? Thanks again. Link to comment https://forums.phpfreaks.com/topic/140561-solved-need-help-with-variable-image-name/#findComment-736174 Share on other sites More sharing options...
dawsba Posted January 13, 2009 Share Posted January 13, 2009 of course this can be done, i'm surprised noone else saw this, easy way CHEAT create static graphics .jpg's etc ach with the number you want and name them dot1.jpg for sq 1 dot2.jpg for 2 and so on {ps dot.jpg of whatever you named the image filenames.} on the line $back[$i] = "<img src=$image_dir/$dot_image $alt>"; change to $back[$i] = "<img src=".$image_dir."/".$dot_image.$i." $alt>"; Hope this helps Link to comment https://forums.phpfreaks.com/topic/140561-solved-need-help-with-variable-image-name/#findComment-736226 Share on other sites More sharing options...
springer- Posted January 13, 2009 Author Share Posted January 13, 2009 of course this can be done, i'm surprised noone else saw this, easy way CHEAT create static graphics .jpg's etc ach with the number you want and name them dot1.jpg for sq 1 dot2.jpg for 2 and so on {ps dot.jpg of whatever you named the image filenames.} on the line $back[$i] = "<img src=$image_dir/$dot_image $alt>"; change to $back[$i] = "<img src=".$image_dir."/".$dot_image.$i." $alt>"; Hope this helps Thanks for the reply. That was close but here is the result I got when implemented. Graphic name b.png rusulted in b.png8 and I am looking for b8.png Any suggestions to correct that? Thanks Link to comment https://forums.phpfreaks.com/topic/140561-solved-need-help-with-variable-image-name/#findComment-736328 Share on other sites More sharing options...
dawsba Posted January 13, 2009 Share Posted January 13, 2009 quick fix swap position of the number in the filename so now u have 8dot.png and 9dot.png and move $i var here $back[$i] = "<img src=".$image_dir."/".$i.$dot_image." $alt>"; Link to comment https://forums.phpfreaks.com/topic/140561-solved-need-help-with-variable-image-name/#findComment-736332 Share on other sites More sharing options...
springer- Posted January 13, 2009 Author Share Posted January 13, 2009 That worked perfectly, THANKS ! Link to comment https://forums.phpfreaks.com/topic/140561-solved-need-help-with-variable-image-name/#findComment-736444 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.