复杂的数组比较

时间:2018-05-28 06:36:55

标签: php mysql

1-我正在构建一个比较应用程序,用于比较两个用户之间的关系。 如果用户A和用户B具有相同的国家/地区地址,则它将向任何相同的相似值打印警报。

2-还有一个问题是某些用户有多个地址,例如用户A的地址为x1,用户b的地址为x1,地址为x2,在这种情况下如何将用户A的地址与用户B的多个地址进行比较并警告两个用户之间的地址x1是否匹配?

此处是对两个用户的查询

$query1 = "
  SELECT
    a.PID, a.`Name`, a.Avatar, a.Email,
    b.City, a.LDate, b.Country, b.MPhone,
    b.Gender, b.Birthday
  FROM
    `Profile` AS a
    LEFT JOIN Details AS b ON a.PID = b.PID
  WHERE
    a.PID = '1'
";
$UserInfo1 = mysqli_query($mysqli, $query1);
while( $row = mysqli_fetch_array($UserInfo1) ){
  $Avatar1 = "{$row['Avatar']}";
  $Name1 = "{$row['Name']}";
  $Email1 = "{$row['Email']}";
  $Country1 = "{$row['Country']}</td>";
  $MPhone1 = "{$row['MPhone']}</td>";
  $Gender1 = "{$row['Gender']}</td>";
  $City1 = "{$row['City']}</td>";
  $Birthday1 = "{$row['Birthday']}</td>";
    }
  $query2 = "
  SELECT
    a.PID, a.`Name`, a.Avatar, a.Email,
    b.City, a.LDate, b.Country, b.MPhone,
    b.Gender, b.Birthday
  FROM
    `Profile` AS a
    LEFT JOIN Details AS b ON a.PID = b.PID
  WHERE
    a.PID = '2'
";
  $UserInfo2 = mysqli_query($mysqli, $query2);
  while( $row = mysqli_fetch_array($UserInfo2) ){
  $Avatar2 = "{$row['Avatar']}";
  $Name2 = "{$row['Name']}";
  $Email2 = "{$row['Email']}";
  $Country2 = "{$row['Country']}</td>";
  $MPhone2 = "{$row['MPhone']}</td>";
  $Gender2 = "{$row['Gender']}</td>";
  $City2 = "{$row['City']}</td>";
  $Birthday2 = "{$row['Birthday']}</td>";
    }

3-最后的结果是我想制作流程图并将匹配的信息指向彼此,如此截图:

enter image description here

在php或Mysql中进行这种比较的最佳和最简单的方法是什么?

非常需要您的帮助。

0 个答案:

没有答案