Show data of associative arrays in an HTML table

0

I need to load this data in a table, an issue that I try to show the headers, but in the header of the dates I need that all these dates in a single column of the table and I do not leave .. Can you help me?

    <?php 


    echo "<p> <h2> Punto 1: de Asistencias de la materia Programación III </h2>   </p>";
    echo "<p> b)_ Tabla en pantalla </p>";


    $alumnos=array( "10"=>"ACOSTA CARLOS ALBERTO",
                    "29"=>"AGUILERA CAPRA JESUS DARIO",
                    "34"=>"AYALA LEANDRO JOSE",
                    "45"=>"BENITEZ DARIO",
                    "52"=>"BRITEZ PABLO FERNANDO",
                    "65"=>"CANESIN LUIS OSCAR",
                    "79"=>"DEGREGORIO NICOLAS EZEQUIEL",
                    "84"=>"FERNANDEZ VICTOR HUGO",
                    "9"=>"BOGADO EZEQUIEL",
                    "103"=>"IZA FEDERICO",
                    "117"=>"GIMENEZ MARIANA ITATI",
                    "124"=>"BRITEZ MENDEL JUNIOR JOEL");


$fechasAsistencias=array("Fechas"=>array("30/09"=>array('-','P','P','P','P','P','P','P','P','P','P','P'),"06/10"=>array('-','P','-','P','P','-','P','-','P','P','-','P'),"07/10"=>array('P','P','P','P','P','P','P','P','P','-','P','P'),"13/10"=>array('P','P','P','-','-','P','P','P','-','P','P','P'),"14/10"=>array('P','-','P','P','-','P','P','-','P','-','P','P'),"20/10"=>array('P','P','-','P','P','-','P','P','-','P','P','-'),"21/10"=>array('P','P','P','P','-','P','P','P','P','-','-','P'),"27/10"=>array('P','P','P','P','P','P','-','P','-','P','-','P')));


    echo "<table border=5 >";

    echo "<thead>";

        echo "<tr>";

            echo "<td> <th> Nro.  </th> </td>";

            echo "<td><th> Apellido y Nombre </th></td>";

//Aqui esta mi problema necesito este encabezado fecha, y las fechas como sub encabezados en la misma columna. el problema es que me muestra uno a lado del otro.. y nose como de otra forma probarle..

        echo "<td><th> Fechas </th> <td>30/09</td><td>06/10</td><td>07/10</td><td>13/10</td><td>14/10</td><td>20/10</td><td>21/10</td><td>27/10</td></td>" ;




        echo "</tr>";



    echo "</thead>";
    echo "<tbody>";

    echo "</tbody>";

echo "</table>";

 ?>
    
asked by Enzo Roa 19.04.2018 в 23:25
source

2 answers

1
<?php


$alumnos=array( "10"=>"ACOSTA CARLOS ALBERTO",
                "29"=>"AGUILERA CAPRA JESUS DARIO",
                "34"=>"AYALA LEANDRO JOSE",
                "45"=>"BENITEZ DARIO",
                "52"=>"BRITEZ PABLO FERNANDO",
                "65"=>"CANESIN LUIS OSCAR",
                "79"=>"DEGREGORIO NICOLAS EZEQUIEL",
                "84"=>"FERNANDEZ VICTOR HUGO",
                "9"=>"BOGADO EZEQUIEL",
                "103"=>"IZA FEDERICO",
                "117"=>"GIMENEZ MARIANA ITATI",
                "124"=>"BRITEZ MENDEL JUNIOR JOEL");

?>

So you want the table?

<table width="100%" border="1">



 <?php

   foreach($alumnos as $key => $value)
      {


 ?>
    <tr> 
           <td>
               <?php echo $key; ?>
         </td>
                 <?php foreach($value as $key=>$value)
                   {
                 ?>
          <td>
                <?php echo $value;?>
         </td>
                <?php
                 }
                ?>
    </tr>




<?php
    }
   ?>

</table>
    
answered by 19.04.2018 / 23:31
source
0

For the part of the dates, you can go through the array that you have defined $ assistance dates ['dates'] indicating the key and the value:

foreach ($fechasAsistencias['fechas'] as $fecha => $lista) {
   // en $fecha tienes 30/09, 07/10 ...
}
    
answered by 19.04.2018 в 23:43