<commit_before><?php include 'header.php'; ?>

<?php function advancedQuery5()
{

    include 'dbConnect.php';
 
  
    ?>
    <div class="container">
    <div class="row">
        <div class="col-md-12">
            <h2 style="text-align:center;">You have searched for all employees that earn more than the average salary</h2>
            <br>
        </div>
    </div>
    <div class="row">
    <div class="col-md-12">
    <table class="table table-striped table-bordered table-condensed" style="width:100%";>
    <thead>
    <tr>
        <th>Forename</th>
        <th>Surname</th>
		<th>Role</th>
		<th>Salary</th>


    </tr>
    </thead>

    <?php
    
        $query = "SELECT forename, surname, role, salary 
					FROM employee, payroll having salary>(SELECT AVG(SALARY) FROM payroll) ORDER BY surname ASC;";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));
        while ($row = mysqli_fetch_array($result)) {
            echo '
                <tbody>
				
                    <td>' . $row[0] . '</td>
                    <td>' . $row[1] . '</td>
					<td>' . $row[2] . '</td>
                    <td>' . $row[3] . '</td>
                    
                </tbody>';
        }
    


}

if (isset($_GET["performquery"])) {
    advancedQuery5();
<commit_msg>Bug fix: Query 5 now operates correctly<commit_after><?php include 'header.php'; ?>

<?php function advancedQuery5()
{

    include 'dbConnect.php';
 
  
    ?>
    <div class="container">
    <div class="row">
        <div class="col-md-12">
			<?php $queryavg = "SELECT AVG(salary) FROM payroll;"; 
			$resultavg = mysqli_query($db, $queryavg) or die(mysqli_error($db));
			$avg = mysqli_fetch_array($resultavg);
			
			?>
            <h2 style="text-align:center;">You have searched for all employees that earn more than the average salary, which is £<?php echo number_format((float)"$avg[0]") ?>.</h2>
            <br>
        </div>
    </div>
    <div class="row">
    <div class="col-md-12">
    <table class="table table-striped table-bordered table-condensed" style="width:100%";>
    <thead>
    <tr>
        <th>Forename</th>
        <th>Surname</th>
		<th>Role</th>
		<th>Salary</th>


    </tr>
    </thead>

    <?php
    
        $query = "SELECT forename,surname,role,salary FROM employee e,payroll p WHERE p.salary > (SELECT AVG(salary) FROM payroll) AND e.employee_id=p.employee_id ORDER BY surname ASC;";
        $result = mysqli_query($db, $query) or die(mysqli_error($db));
        while ($row = mysqli_fetch_array($result)) {
            echo '
                <tbody>
				
                    <td>' . $row[0] . '</td>
                    <td>' . $row[1] . '</td>
					<td>' . $row[2] . '</td>
                    <td>' . $row[3] . '</td>
                    
                </tbody>';
        }
    


}

if (isset($_GET["performquery"])) {
    advancedQuery5();

{'fraction_non_alphanumeric': 0.17297672803056616, 'fraction_numerical': 0.011114970475859673, 'mean_word_length': 1.9968782518210197, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6399690', 'n_tokens_mistral': 1044, 'n_tokens_neox': 946, 'n_words': 214}