让两个用户都使用Ajax

How is it possible for me to get user one and user 2's information back through and Ajax request. Must I do two separate queries like so?

$check = "SELECT * FROM user WHERE id='$user1_id'";
$check1 = mysqli_query($mysqli,$check);
$resultArr = mysqli_fetch_array($check1);
$json['username'] = ucfirst($resultArr['username']);
$json['id'] = $resultArr['id'];
$json['first'] = ucfirst($resultArr['first']);
$json['middle'] = ucfirst($resultArr['middle']);
$json['last'] = ucfirst($resultArr['last']);
mysqli_free_result($check1);

$check2 = "SELECT * FROM user WHERE id='$user2_id'";
$check12 = mysqli_query($mysqli,$check2);
$resultArr2 = mysqli_fetch_array($check12);
$json['username'] = ucfirst($resultArr2['username']);
$json['id'] = $resultArr2['id'];
$json['first'] = ucfirst($resultArr2['first']);
$json['middle'] = ucfirst($resultArr2['middle']);
$json['last'] = ucfirst($resultArr2['last']);
mysqli_free_result($check2);

And when returned I have - '+datamessage['first']+' >> '+datamessage['first']+' problem is they swap positions in the server side depending on who's sent the message so user 2's name could be first or user1's could be first.

$check = "SELECT * FROM user WHERE id='$user1_id'";
$check1 = mysqli_query($mysqli,$check);
$resultArr = mysqli_fetch_array($check1);
$json1['username'] = ucfirst($resultArr['username']);
$json1['id'] = $resultArr['id'];
$json1['first'] = ucfirst($resultArr['first']);
$json1['middle'] = ucfirst($resultArr['middle']);
$json1['last'] = ucfirst($resultArr['last']);
mysqli_free_result($check1);

$check2 = "SELECT * FROM user WHERE id='$user2_id'";
$check12 = mysqli_query($mysqli,$check2);
$resultArr2 = mysqli_fetch_array($check12);
$json2['username'] = ucfirst($resultArr2['username']);
$json2['id'] = $resultArr2['id'];
$json2['first'] = ucfirst($resultArr2['first']);
$json2['middle'] = ucfirst($resultArr2['middle']);
$json2['last'] = ucfirst($resultArr2['last']);
mysqli_free_result($check2);

$json = array(
    'user1' => $json1,
    'user2' => $json2,
);
  $check = "SELECT * FROM user WHERE id in ('$user1_id','$user1_id')";
  $res= mysqli_query($mysqli,$check);
  $i=0;
  while($resultArr = mysqli_fetch_array($res))
  {
       $json[$i]['username'] = ucfirst($resultArr['username']);
       $json[$i]['id'] = $resultArr['id'];
       $json[$i]['first'] = ucfirst($resultArr['first']);
       $json[$i]['middle'] = ucfirst($resultArr['middle']);
       $json[$i]['last'] = ucfirst($resultArr['last']);
       $i++;
 }
 return json_decode($json);
 //hope it will work for you