Jump to content

little problem with variables


desithugg

Recommended Posts

[code]
$query = mysql_query("SELECT * FROM battle where my_name = '$user_in'") or die(mysql_error());
$row = mysql_fetch_array( $query );
$mpon = $row["my_poke_on"];
$opp_name = $row["opp_name"];
$my_poke1 = $row["my_poke1"];
$my_poke2 = $row["my_poke2"];
$my_poke3 = $row["my_poke3"];
$mp1name = reverse_strrchr($my_poke1, '#');
$mp1name = strrchr($mp1name, '@');
$mp1name = str_replace(array_keys($bfilter), array_values($bfilter), $mp1name);
$mp2name = reverse_strrchr($my_poke2, '#');
$mp2name = strrchr($mp2name, '@');
$mp2name = str_replace(array_keys($bfilter), array_values($bfilter), $mp2name);
$mp3name = reverse_strrchr($my_poke3, '#');
$mp3name = strrchr($mp3name, '@');
echo problem here;
[/code]
I want to echo $mp(# depending on value of $mpon)name
how can i do this...srry if im confusing dont know how else to put it
Link to comment
https://forums.phpfreaks.com/topic/27712-little-problem-with-variables/
Share on other sites

umm nvm i figured out a way to get around it...i just assigned new variables depending on the value of $mpon
[code]
if($mpon == "1")
{
$my_poke_show_name = $mp1name;
$my_poke_show_hp = $mp1hp;
$my_poke_show_hp_full = $mp1hp_full;
$my_poke_show_hp_bar = $mp1hp_bar;
$my_poke_show_level = $mp1level;
}
if($mpon == "2")
{
$my_poke_show_name = $mp2name;
$my_poke_show_level = $mp2level;
$my_poke_show_hp = $mp2hp;
$my_poke_show_hp_full = $mp2hp_full;
$my_poke_show_hp_bar = $mp2hp_bar;
}
if($mpon == "3")
{
$my_poke_show_name = $mp3name;
$my_poke_show_hp = $mp3hp;
$my_poke_show_hp_full = $mp3hp_full;
$my_poke_show_hp_bar = $mp3hp_bar;
$my_poke_show_level = $mp3level;
}
if($mpon == "4")
{
$my_poke_show_name = $mp4name;
$my_poke_show_hp = $mp4hp;
$my_poke_show_hp_full = $mp4hp_full;
$my_poke_show_hp_bar = $mp4hp_bar;
$my_poke_show_level = $mp4level;
}
if($mpon == "5")
{
$my_poke_show_name = $mp5name;
$my_poke_show_hp = $mp5hp;
$my_poke_show_hp_full = $mp5hp_full;
$my_poke_show_hp_bar = $mp5hp_bar;
$my_poke_show_level = $mp5level;
}
if($mpon == "6")
{
$my_poke_show_name = $mp6name;
$my_poke_show_hp = $mp6hp;
$my_poke_show_hp_full = $mp6hp_full;
$my_poke_show_hp_bar = $mp6hp_bar;
$my_poke_show_level = $mp6level;
}
echo $my_poke_show_name;
[/code]
so yeah dont know why i didnt think of this earlier lol...

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.