pull record and filter from mysql pro php [closed]

0

I'm trying to pull the information in MySql and show in php, with a filter in the room name

$reserva = mysqli_query($connect, 'select * from reserva join curso on reserva.idCurso = curso.idCurso join professor on reserva.idProfessor = professor.idProfessor join sala on reserva.idSala = sala.idSala;');
$reservaArray = mysqli_fetch_array($reserva);
$selectSala = mysqli_query($connect, 'SELECT * FROM sala') or die('Deu erro');
    while($teste = mysqli_fetch_array($selectSala)){
        $arraySala[] = $teste['nomeSala'];
    }

for ($sala=9; $sala<=20; $sala++){
          echo   '<tr>
                 <th scope="row">'.$arraySala[$sala].'</th>
                 <td colspan="3" class="text-center">';
                       if($arraySala[$sala] == $reservaArray['nomeSala']){
                             echo $reservaArray['idCurso'].' - '.$reservaArray['nomeCurso'].' - '.$reservaArray['nomeProfessor']; 
                        }

                  echo'</td>
          </tr>';
      }

There are 3 records, but only the first one is shown. I already tried using while but could not execute

    
asked by anonymous 17.10.2018 / 03:46

1 answer

0

What I was able to notice is that it is passing in the index of the array, and is starting with 9, the array starts with index 0, and in that case it would be simpler to use a foreach as well.

for ($sala=0; $sala<=20; $sala++){
          echo   '<tr>
                 <th scope="row">'.$arraySala[$sala].'</th>';
}

foreach (arraySala $value){
//conteúdo do loop
}

You can get more details on using foreach at: link

    
17.10.2018 / 12:47