How does the modification of the SQL query in the PHP code affect the output of the array data?

The modification of the SQL query in the PHP code can affect the output of the array data by changing the data being retrieved from the database. To solve this issue, ensure that the SQL query is correctly structured to fetch the desired data from the database table.

// Original SQL query
$sql = "SELECT * FROM users WHERE role = 'admin'";

// Modified SQL query to fetch specific columns
$sql = "SELECT id, username, email FROM users WHERE role = 'admin'";

// Execute the SQL query and fetch data into an array
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data of each row
    $data = array();
    while($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
    print_r($data);
} else {
    echo "0 results";
}