How to know the index number in a multidimensional array? [closed]

1

Information:
Rooms: 25;
Teachers: 4;
Q02, Q03, Q04: A student in a class ranked the teacher from 0 to 10. From these numbers, an average was generated.

There is a select with the list of teachers, and when one is selected, I need to display ALL rooms that are the same from the class (done), his position (from the four teachers) based on the average (IN SAME ROOM) , this for Q02, Q03 and Q04. There is also a general concept media, which will be done not only with the teachers who give classes in that class, but also all teachers in all classrooms.

  

EXPLANATION OF ARRAY

  

EXPECTEDOUTCOME

  

BANKDATASAMPLE

  

SCRIPT:

<?phprequire'config.php';$nomeProfessor=(isset($_POST['frmProfessor']))?addslashes($_POST['frmProfessor']):'ABNER';//LISTATODOSOSPROFESSORES$listaProfessor=newRead;$listaProfessor->FullRead("SELECT Nome FROM ang_relatorio GROUP BY Nome");

//LISTA TODAS AS SALAS DO PROFESSOR
$listaSalaProfessor = new Read;
$listaSalaProfessor->FullRead("SELECT Sala, Nome FROM ang_relatorio WHERE Nome=:professor GROUP BY Sala", "professor={$nomeProfessor}");

//LISTA TODAS AS SALAS
$todasSalas = new Read;
$todasSalas->FullRead("SELECT Sala FROM ang_relatorio GROUP BY Sala");

$media = new Read;
//SELECIONA A MEDIA DO PROFESSOR EM UMA SALA E ARMAZENA EM UM ARRAY
foreach ($listaSalaProfessor->getResult() as $key => $sala):
    extract($sala);
    $media->FullRead('SELECT (AVG(Q02) + AVG(Q03) + AVG(Q04)) / 3 FROM ang_relatorio WHERE Nome=:professor AND Sala=:sala', "professor={$nomeProfessor}&sala={$Sala}");
    $mediaProfessorSala[] = $media->getResult();
endforeach;

foreach ($todasSalas->getResult() as $key => $sala):
    extract($sala);
    $selecionaSala = new Read;
    $selecionaSala->FullRead("SELECT Nome, Sala, (AVG(Q02) + AVG(Q03) + AVG(Q04)) / 3 FROM ang_relatorio WHERE Sala=:sala GROUP BY Nome ORDER BY (AVG(Q02) + AVG(Q03) + AVG(Q04)) / 3 DESC", "sala={$Sala}");
    $professoresSala[] = $selecionaSala->getResult();
endforeach;

//RETORNA O CONCEITO DO PROFESSOR REFERENTE AOS OUTROS
function Conceito($posicao) {
    if ($posicao <= 7):
        return 'C';
    elseif ($posicao >= 8 && $posicao <= 14):
        return 'B';
    elseif ($posicao >= 15 && $posicao <= 21):
        return 'A';
    else:
        return 'Posição incorreta.';
    endif;
}
?>

<!DOCTYPE html>
<html lang="pt-br">
    <head>
        <meta charset="utf-8">
        <title>Relatórios</title>
        <link rel="stylesheet" href="<?= URL; ?>/assets/css/bootstrap.css"/>
        <link rel="stylesheet" href="<?= URL; ?>/assets/css/awesome.css"/>
        <link rel="stylesheet" href="<?= URL; ?>/assets/css/estilo.css"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <div class="container">

            <form method="POST">
                <select name="frmProfessor" class="form-control" onchange="this.form.submit()">
                    <?php
                    foreach ($listaProfessor->getResult() as $key => $professor):
                        extract($professor);
                        $selected = ($Nome == $nomeProfessor) ? 'selected' : '';
                        echo "<option value='{$Nome}' $selected>{$Nome}</option>";
                    endforeach;
                    ?>
                </select>
            </form>

            <table class="table table-bordered">
                <tr>
                    <th>#SALA</th>
                    <th>#Q02</th>
                    <th>#Q03</th>
                    <th>#Q04</th>
                </tr>
                <tr>
                    <td>SALA</td>
                    <td>POSIÇÃO DO PROFESSOR REFERENTE AOS OUTROS COM BASE NA MEDIA DE Q02</td>
                    <td>POSIÇÃO DO PROFESSOR REFERENTE AOS OUTROS COM BASE NA MEDIA DE Q03</td>
                    <td>POSIÇÃO DO PROFESSOR REFERENTE AOS OUTROS COM BASE NA MEDIA DE Q04</td>
                </tr>
            </table>
        </div>
    </body>
</html>
    
asked by anonymous 21.09.2016 / 17:28

0 answers