title: Convert php query result into json
body: <p>I have the following code that queries multiple tables to get information about activities. I would like to convert the query result into array and call it whenever needed.
  My question is: can this query be converted into array?</p>
  
  <pre><code>&lt;?php
  function view_full_activity($activity_field){
              global $connection;
  
          $contact_id = $_REQUEST['contact_id'];
          $activity_id = $_REQUEST['activity_id'];
          $get = "SELECT * FROM activity_base WHERE activity_id = '$activity_id' "
                                      or die("Error: ".mysqli_error($connection));
          $query = mysqli_query($connection, $get);
      //Get activity base information
          while ($activity = mysqli_fetch_array($query)){
              $activity_related_to_id = $activity ['activity_related_to_id'];
              $activity_id = $activity['activity_id'];
              $activity_type_id = $activity['activity_type_id'];
        $activity_entity_type_id = $activity['activity_entity_type_id'];
              $activity_title = $activity['activity_title'];
              $activity_due_date = $activity['activity_due_date'];
              $activity_created_by = $activity['activity_created_by'];
              $activity_created_on = $activity['activity_created_on'];
              $activity_status_code_id = $activity['activity_status_code_id'];
              $activity_type_icon;
              $activity_due_date = $activity['activity_due_date'];
        $activity_create_date = date("m-d-Y", strtotime($activity['activity_created_on']));
  
        //Reverse Date
        $activity_due_date = date("m-d-Y ", strtotime($activity_due_date));
  
              if ($activity_type_id == "1"){
                  $activity_type_icon = "fa fa-envelope";
              }else if ($activity_type_id == "3"){
                  $activity_type_icon = "fa fa-suitcase";
              }else if ($activity_type_id == "2"){
                  $activity_type_icon = "fa fa-phone";
              }
  
        if ($activity_entity_type_id == "1") {
          $acitvity_url = "acct_id";
          $acitivty_is_for ="accounts_base";
          $page_url = "account-profile.php";
        }else if ($activity_entity_type_id == "2") {
          $acitvity_url = "contact_id";
          $acitivty_is_for ="contacts";
          $page_url = "contact-profile.php";
        }else if ($activity_entity_type_id == "3") {
          $acitvity_url = "contact_id";
          $acitivty_is_for ="contacts";
          $page_url = "contact-profile.php";
        }
            //Get detailed activity information 
        //If activity is Email
      if ($activity_type_id == "1") {
          $email_details = email_activity_details($activity_id);
          while ( $email = mysqli_fetch_assoc($email_details)) {
            $activity_details = nl2br($email['email_message']);
  
          }
      }else if ($activity_type_id == "2") {
          $call_details = call_activity_details($activity_id);
          while ( $call = mysqli_fetch_assoc($call_details)) {
            $activity_details = $call['call_details'];
            }
          }else if ($activity_type_id == "3") {
          $meeting_details = meeting_activity_details($activity_id);
          while ( $meeting = mysqli_fetch_assoc($meeting_details)) {
            $activity_details = $meeting['meeting_details'];
            }
          }
          //Get creator user info
            $user_query = get_user_info($activity_created_by);
            while ($user = mysqli_fetch_array($user_query)) {
              $activity_created_by = $user['user_full_name'];
            }
      }
  
      }     
  
  
  
            ?&gt;
  </code></pre>