There is a code:

$myatk = mysql_query("SELECT * FROM atk WHERE name='".$_GET['value']."' "); $atk = mysql_query($myatk); $mysql = mysql_query("SELECT * FROM user_pokemon WHERE username='".$_SESSION['username']."' and start='$on'"); $row = mysql_fetch_array($mysql); 

The question is how to do this:

 $uron = $row['$atk['type']']; 
  • Most likely, $uron = $row[$atk['type']]; but I wonder where is the logic? - Palmervan
  • the structure of the tables in the studio,> $ row ['$ atk [' type ']']; // This is bad! and never wrong. The task is what, the question correctly articulate. - Artem
  • I make a browser game, and this is part of the battle, and there are two types of attack, Special Attack and Physical Attack, then we pull out the attack that the user used and see if this is a physical attack, then we take away the bot's life from the Attack Physical attack, and if the user used Spec.Ataku, then we take away the life of the bot from the stat of Spec.Attack, Stat is an indicator of the damage of the hero - oOKomarOo

1 answer 1

 $myatk = mysql_query("SELECT * FROM atk WHERE name='".$_GET['value']."' "); $atk = mysql_query($myatk); 

Cheet at all?

 $myatk = mysql_query("SELECT * FROM atk WHERE name='".mysql_real_escape_string($_GET['value'])."' "); $atk = mysql_fetch_assoc($myatk); $mysql = mysql_query("SELECT * FROM user_pokemon WHERE username='".mysql_real_escape_string($_SESSION['username'])."' and start='$on'"); $row = mysql_fetch_assoc($mysql); $uron = $row[$atk['type']]; 
  • It doesn’t matter what it is, we are> SELECT * FROM atk WHERE name = '". $ _ GET [' value ']."' ". $ _ GET ['value']." '"Will not choose 1K of the same values. - Artem
  • I just fixed 2 errors. 1. $ atk = mysql_query ($ myatk); you need $ atk = mysql_fetch_assoc ($ myatk); 2. changed the fetch_array to mysql_fetch_assoc (because fetch arrey returns an array with numeric keys) - Alex Kapustin