repeat data from the same query

0

Well, I'm breaking my head trying to find a solution.

$query_listserv = "SELECT * FROM servicos ORDER BY nome ASC";
$result_listserv = mysqli_query($conectar, $query_listserv);

while ($linhas_listserv = mysqli_fetch_assoc($result_listserv)){

   $servicos = $linhas_listserv['nome'];

   $buscatotala = "SELECT * FROM dia WHERE dia='$datec' AND func='Alex' AND servicos LIKE '%$servicos%'";
   $resultado_totala = mysqli_query($conectar, $buscatotala);
   $totala = mysqli_num_rows($resultado_totala);

   echo "
      <tr>
         <td>".$linhas_listserv['nome']."</td>
         <td>";
         if ($totala != '0'){
             echo "<font color='red'>";
         }
         echo $totala."</font></td>
      </tr>";
}

I use this code to perform a query that returns me the amount of services performed on the day. but how do I repeat the same query for the other employees in different div's? without having to repeat the lines:

$query_listserv = "SELECT * FROM servicos ORDER BY nome ASC";
$result_listserv = mysqli_query($conectar, $query_listserv);

while ($linhas_listserv = mysqli_fetch_assoc($result_listserv)){

$servicos = $linhas_listserv['nome'];
    
asked by anonymous 02.12.2018 / 05:06

0 answers