将静态值映射到另一个静态值


Mapping a static value to a static value

我试图从用户输入的值的数组映射一些值。这里$actual来自user, $target来自一个表

if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
else
{
    $actual; 
    $comment; $con;
    foreach($_POST['value']  as $country => $value1 ){
        foreach($value1  as $goal => $value2){
                    //value => ["matrix"]
                    foreach($value2 as   $matrix => $value3){
                            //value => string 
                             $country ." ". $goal." " .$matrix. " " . $value3."<br/>";  
                            if($matrix == "actual"){
                                $actual = $value3;  
                            }else if($matrix=="comment"){
                                $comment=$value3;
                            }
                    }
              $sql="SELECT target FROM target where ini_id = '$ini' and country_id='$country' and metric_id='$goal'"; 
              $result=mysql_query($sql);
              $target = mysqli_fetch_array($result);

                insert($actual,$target['target'],$country.$ini.$goal ,$comment,$con);

警告:mysqli_fetch_array()期望参数1为mysqli_result,布尔值在C:'xampp'htdocs'xampp'Testing'sq1.php on line 107

我看到的问题是你使用mysql_query而不是mysqli_query

(因此mysqli_fetch_array并不真正知道如何解释该参数)