Jump to content

Is there a way??


almightyegg

Recommended Posts

As I said last time you where playing with this idea, you need to rethink your logic. $variables simply hold values, they can be named whatever, but dynamically naming variables and trying to manipulate them in such a way is not usually the right way of going about things.

 

Maybe if you explained the bigger picture we could offer an alternative.

Link to comment
https://forums.phpfreaks.com/topic/98702-is-there-a-way/#findComment-507720
Share on other sites

It's needed in this function type thing:

$im = imagecreate(150, 100);

$i = 1;
$h = 1;
while($i <> 16 && $h <> 11){
$p = ${"p" . $i . "d" . $h};
$f = ($i-1)*10;
$s = $i*10;
$g = ($h-1)*10;
$r = $h*10;

$black = imagecolorallocate($im, 102, 51, 0);
$red = imagecolorallocate($im, 255, 0, 0);
$brown = imagecolorallocate($im, 255, 147, 28);
$turq = imagecolorallocate($im, 153, 255, 255);

$flares = mysql_fetch_array(mysql_query("SELECT * FROM itemsowned WHERE userid = '{$mem['id']}' and code = 'flar'"));
$vmap = mysql_fetch_array(mysql_query("SELECT * FROM itemsowned WHERE userid = '{$mem['id']}' and code = 'vmap'"));
$flares = $flares[amount];
$vmap = $vmap[amount];

if($p == x){
imagefilledrectangle($im, $f, $g, $s, $r, $black);
}elseif($p == v && $vmap == 1){
imagefilledrectangle($im, $f, $g, $s, $r, $turq);
}elseif($p == m && $vmap == 1){
imagefilledrectangle($im, $f, $g, $s, $r, $turq);
}else{
imagefilledrectangle($im, $f, $g, $s, $r, $brown);
}

if($i == 15 && $h == 10){
$h = $h+1;
$i = $i+1;
}elseif($i == 15){
$i = 1;
$h = $h+1;
}else{
$i = $i+1;
}

}

 

This works (mostly) but I want to add another if.

 

Basically I want to say if(the-point-the-user-is-on == p$id$h){ etc..

 

That make more sense?

Link to comment
https://forums.phpfreaks.com/topic/98702-is-there-a-way/#findComment-507727
Share on other sites

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.