0
have a variable $servicos
that receives the list of services registered in the BD through this code.
$query_servicos = "SELECT * FROM servicos ORDER BY nome ASC";
$result_servicos = mysqli_query($conectar, $query_servicos);
$servicos = array();
while ($linhas_servicos = mysqli_fetch_assoc($result_servicos)){
$servicos[] = $linhas_servicos['nome'];
}
$servicos = implode( ' ', $servicos);
I need to separate the data to list and perform a query.
$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);
// Preciso que essa parte se repita, preenchendo a tabela com os dados do funcionário.
echo "
<tr>
<td>".$servicos[]."</td>
<td>";
if ($totala != '0'){
echo "<font color='red'>";
}
echo $totala."</font></td>
</tr>";
so could ease the code, why would not repeat the query listing the services, in the next officials.
EX: NEXT OFFICIAL:
$buscatotali = "SELECT * FROM dia WHERE dia='$datec' AND func='Italo' AND servicos LIKE '%$servicos%'";
$resultado_totali = mysqli_query($conectar, $buscatotali);
$totali = mysqli_num_rows($resultado_totali);
echo "
<tr>
<td>".$servicos[]."</td>
<td>";
if ($totali != '0'){
echo "<font color='red'>";
}
echo $totali."</font></td>
</tr>";
whole code for an employee (I am repeating the same code for the other employees just by swapping the termination of the $ with the initial letter corresponding to the employee):
<div class="accrodion-regular">
<div id="accordion3">
<div class="card my-0">
<div class="card-header1" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
<span class="fas mr-3 fa-angle-down"></span>Serviços
</button>
</h5>
</div>
<div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordion3" style="">
<div class="card-body p-0">
<div class="table-responsive">
<table class="table no-wrap p-table">
<tbody>
<?php
$query_listserva = "SELECT * FROM servicos ORDER BY nome ASC";
$result_listserva = mysqli_query($conectar, $query_listserva);
while ($linhas_listserva = mysqli_fetch_assoc($result_listserva)){
$servicosa = $linhas_listserva['nome'];
$buscatotala = "SELECT * FROM dia WHERE dia='$datec' AND func='Alex' AND servicos LIKE '%$servicosa%'";
$resultado_totala = mysqli_query($conectar, $buscatotala);
$totala = mysqli_num_rows($resultado_totala);
echo "
<tr>
<td>".$servicosa."</td>
<td>";
if ($totala != '0'){
echo "<font color='red'>";
}
echo $totala."</font></td>
</tr>";
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
Aloha Rapha, show but the idea was to return the data of the 3 employees at the same time in different div’s...
– Ronaldo de Lima
So let me get this straight, I’m going to input what data into the search so that you can get the result? Just to know so I can make the modification in the code.
– Rapha Leão
I edited with the complete code, there is no search, the page is a "Dashboard" and I need to bring the data of each employee at the same time on the same page. (div "Alex", div "Italo", div "Naldo"...) what I’m doing is repeating all the code by changing the func=' ' with each one’s name and the $ terminations with the employee’s initial.
– Ronaldo de Lima
This is weighing, so far the page already makes 4 queries that return the list of services. the idea is to make only 1 and use to fetch the data of each of the employees.
– Ronaldo de Lima
Got it, so it’s really just query through query right? No queries through forms...
– Rapha Leão
this, only the Query to show the data
– Ronaldo de Lima