order problems on the page

0

I have a problem with the HTML and PHP listing because they do not show me the data properly

The goal is to show me this way

But I get it this way

<form action="ListadoCompletoBuscarSensor1.php" >

        Nombre de la primera persona:
        <select name="nombre1">
            <?php
            $listado1 = $dao->ListadoPorPersona();
            foreach ($listado1 as $value) {
                echo "<option>" . $value . "</option>";
            }
            ?>
        </select>

        Nombre de la Segunda Persona
        <select name="nombre2">
            <?php
            $listado2 = $dao->ListadoPorPersona();
            foreach ($listado1 as $value) {
                echo "<option>" . $value . "</option>";
            }
            ?>
        </select>


        <input type="submit" value="Listar Por Sensor" name="btnListarPersona" />           
    </form>
    <?php
    $nombre1 = $_GET['nombre1'];
    $nombre2 = $_GET['nombre2'];        



    $r = $dao->ListadoAgrupadoPorPersona($nombre1, $nombre2);

    echo '<table class="table-fill">';


    echo '<th class="text-left">' . $nombre1. '</th>' .
    '<th class="text-left">' . $nombre2. '</th>' .


    foreach ($r as $list) {

        if ($list->getEquipo() == $nombre1) {
            foreach ($r as $value) {
                echo '<tbody class="table-hover">';
                echo '<tr>';
                echo '<td class="text-left">' . $value->getValor() . '</td>';
                //echo '<td class="text-left">' . $value->getFecha().  '</td>';
            }
        }
        if ($list->getEquipo()==$nombre2) {
            foreach ($r as $value) {
                echo '<td class="text-left">' . $value->getValor() . '</td>';
                echo '</tr>';
                echo '</tbody>';
            }
        }
        echo '</table';
    }
  

    
asked by FranciscoBarreraPeñaloza 22.06.2017 в 20:47
source

1 answer

0

the problem you have in how you are building the table, so that the data is assembled in a correct way your code would be like this:

echo '<table class="table-fill">';    
    echo    '<th class="text-left">' . $sensor1 . '</th>' .
            '<th class="text-left">' . $sensor2 . '</th>' .
    echo    '<tbody class="table-hover">';

    foreach ($r as $list) {
        echo '<tr>';
        if ($list->getEquipo() == $sensor1) {                
            foreach ($r as $value) {             
                echo '<td class="text-left">' . $value->getValor() . '</td>';
                //echo '<td class="text-left">' . $value->getFecha().  '</td>';
            }
        }
        if ($list->getEquipo()==$sensor2) {
            foreach ($r as $value) {
                echo '<td class="text-left">' . $value->getValor() . '</td>';                                        
            }               
        }
        echo '</tr>';
    }
    echo '</tbody>';
echo '</table';

You must remember that the cycles are to fill the "tr" rows of the table

    
answered by 22.06.2017 в 21:48