Show MYSQL results in Horizontal

1

I have the database of DATA created in this format.

the code you use for the query is the following: only that the class table increases The column Bimester to demilitar the query.

<table class="table table-bordered table-striped table-hover"> 

         <tbody>
         <tr>
          <td>N°</td>
          <td class="warning"><H3>APELLIDOS Y NOMBRES</H3></td>

<?php 
$consulta="SELECT * FROM clase WHERE bimestre='1BIM'";

$resultado=$link->query($consulta);

foreach ($resultado as $dia) {
    echo "<td>".$dia['fecha']."</td>";

}// cierra el foreach

echo "</tr>";

$tabla1="alumno";
$tabla2="lista";
$tabla3="clase";
$consultax="SELECT $tabla1.id,$tabla1.ap,$tabla1.am,$tabla1.nom,$tabla2.alumno_id,$tabla2.clase_id,$tabla2.estado FROM $tabla1,$tabla2 WHERE $tabla1.id=$tabla2.alumno_id ";
$resultadox=$link->query($consultax);
while ($row=$resultadox->fetch_array()) {
    $ap=$row['ap'];
    $am=$row['am'];
    $nom=$row['nom'];
    $id=$row['id'];
    $estado=$row['estado'];

    echo "<tr>";
    echo"<td>".$id."</td>";
    echo "<td>".$ap." ".$am." ".$nom."</td>";
    echo "<td>".$estado."</td>";
    echo "</tr>";
}


?>                        
</tbody>
</table>

the final result would have to be like this:  in advance I would appreciate your help.

    
asked by Milton W. Orellana 18.02.2017 в 18:09
source

1 answer

1

the database as well as the samples makes things a little easier. I would separate the structure into 3 tables: (The names of the tables are supposed)

Then, with PHP you can achieve an output like the one you propose. I hope I have helped you, let me know if you need help to continue. Greetings.

    
answered by 18.02.2017 в 23:46