pull registry and filter from mysql pro php

Asked

Viewed 26 times

0

I’m trying to pull the information in Mysql and show it in php, with a filter in the name of the room

$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’ve tried using the while but I couldn’t execute

  • this is the second part of the table, so I started 1 more than the previous

  • Hello @Jhonata Welcome to Stackoverflow, please add the code that queries the database to supplement the question

1 answer

0


what I noticed is that it is passing in the index of the array, and it is starting with 9, the array starts with index 0, in which case it would also be simpler to use a foreach.

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 the use of foreach in: http://php.net/manual/en/control-structures.foreach.php

Browser other questions tagged

You are not signed in. Login or sign up in order to post.