how can I show the data of my delegation column only once without showing it in my table

3

I show the code where I make my query by delegations, and I show them in a table, what I want is that the delegations field does not show them in the table since the data are the same, that is, the same delegation, so I want it to appear on the top of my table only once, so that the user knows that all the data in the table belong to that delegation !! I hope you can help me, please.

<?php
$conect = new mysqli("localhost", "onethost_horacio", "MPADT-2018", "onethost_MPA");
$v3=$_POST['codigo'];
//$sql= "SELECT * from InformacionGeneral WHERE Delegacion like '%$v3%'";
$sql = "SELECT * from TablaNinos inner join InformacionGeneral ON TablaNinos.Id_General=InformacionGeneral.Id_General WHERE Delegacion like '%$v3%'";
$resultado=mysqli_query($conect,$sql);
while($fila=mysqli_fetch_assoc ($resultado)){
?>     
      <tr>
        <td><?php echo $fila["Id_nino"]?></td>  
        <td><?php echo $fila["Nombre"]?></td>
        <td><?php echo $fila["Cargo"]?></td>
        <td><?php echo $fila["Curp"]?></td>
        <td><?php echo $fila["Telefono"]?></td>
        <td><?php echo $fila["Fecha_registro"]?></td>  
        <td><?php echo $fila["Id_General"]?></td>  
        <td><?php echo $fila["Delegacion"]?></td>
        <td><?php echo $fila["Parroquia"]?></td>
        <td><?php echo $fila["Tios_Rensponsables"]?></td>
        <td><?php echo $fila["Asessor_Espiritual"]?></td>
        <td><?php echo $fila["Fecha"]?></td>
        <td><?php echo $fila["Tios_apoyo"]?></td>
        </tr>   
      <?php
 }

?>
    
asked by Jose Luis Santiago Pacheco 02.09.2018 в 06:47
source

2 answers

1

I share the solution friends, I hope someone serves, I just printed with a echo the option that the user selected at the time of your search, that data was saved in the variable $ s3, printed out of the while.

<?php
$conect = new mysqli("localhost", "onethost_horacio", "MPADT-2018", "onethost_MPA");
$v3=$_POST['codigo'];
//$sql= "SELECT * from InformacionGeneral WHERE Delegacion like '%$v3%'";
$sql = "SELECT * from TablaNinos inner join InformacionGeneral ON TablaNinos.Id_General=InformacionGeneral.Id_General WHERE Delegacion like '%$v3%'";
$resultado=mysqli_query($conect,$sql);
while($fila=mysqli_fetch_assoc ($resultado)){
?>    
      <tr>
        <td><?php echo $fila["Nombre"]?></td>
        <td><?php echo $fila["Cargo"]?></td>
        <td><?php echo $fila["Curp"]?></td>
        <td><?php echo $fila["Telefono"]?></td>
        <td><?php echo $fila["Fecha_registro"]?></td>  
        <td><?php echo $fila["Parroquia"]?></td>
        <td><?php echo $fila["Tios_Rensponsables"]?></td>
        <td><?php echo $fila["Asessor_Espiritual"]?></td>
        <td><?php echo $fila["Fecha"]?></td>
        <td><?php echo $fila["Tios_apoyo"]?></td>
        </tr>   
      <?php
 }

?>
<p>Delegacion:<? echo $v3?></p>
    
answered by 02.09.2018 в 08:54
0

If you eliminate the td that has the delegations and you incorporate the data in the variable $delegacion , then you can use it outside the while . However, without the complete code it is difficult to order it to achieve what you want to do, since the rest of the table is missing. It may be necessary to concatenate the results in another variable and print it later, but this depends on the rest of the code.

<?php
    while($fila=mysqli_fetch_assoc ($resultado)){
    $delegacion = $fila["Delegacion"];
?>     
      <tr>
        <td><?php echo $fila["Id_nino"]?></td>  
        <td><?php echo $fila["Nombre"]?></td>
        <td><?php echo $fila["Cargo"]?></td>
        <td><?php echo $fila["Curp"]?></td>
        <td><?php echo $fila["Telefono"]?></td>
        <td><?php echo $fila["Fecha_registro"]?></td>  
        <td><?php echo $fila["Id_General"]?></td>  
        <td><?php echo $fila["Parroquia"]?></td>
        <td><?php echo $fila["Tios_Rensponsables"]?></td>
        <td><?php echo $fila["Asessor_Espiritual"]?></td>
        <td><?php echo $fila["Fecha"]?></td>
        <td><?php echo $fila["Tios_apoyo"]?></td>
        </tr>   
<?php } ?>
    
answered by 02.09.2018 в 08:19