Jump to content

[SOLVED] Need help with variable image name


springer-

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.