首页 > 解决方案 > 合并/合并两个 mysqli_fetch_assoc 数组

问题描述

我有来自 mysqli_fetch_assoc 的 2 个数组,来自 2 个不同服务器的 2 个不同数据库。我的主要辅助服务器被我的办公室联合禁用和 root 禁用所以我决定通过 php fetch assoc 调用手动 .. 这是我在表中的结果

NO. USERID  USERNAME    USERSTATUS  other   NAME
1   1   daffa   1   2   Sugeng
2   2   meito   1   4   Sugeng lagi

不。USERID USERNAME USERSTATUS 行来自 $new_array1 其他 NAME 来自 $new_array2

那么这是我的代码

$i = 1;
while(($new_array1 = mysqli_fetch_assoc( $result1)) && ($new_array2 = mysqli_fetch_assoc( $result2))){
  echo '
      <tr>
          <td>'.$i.'</td>
          <td>'.$new_array1['userid'].'</td>
          <td>'.$new_array1['username'].'</td>
          <td>'.$new_array1['userstatus'].'</td>
          <td>'.$new_array2['other'].'</td>
          <td>'.$new_array2['NAME'].'</td>
      </tr>
  ';
  $i++;
}

但是还有 2 个数组,如何从 fetch assoc 中合并 2 个数组?我想让它成为单个数组,然后显示数据

标签: phpmysqlsqlmysqli

解决方案


推荐阅读