I can not display populated data in divs separated by columns

0

I want to display data from a table by divs with columns of a specific size for each of them, but when I load the information it brings all of them into the same column, I do not want to use table tags to format them. See how it's popping up here.

echo"<div class='col-md-2'>";

                            echo "<div class='widget widget-default widget-item-icon'>";
                                echo "<div class='widget-item-left'>";
                                    echo "<span class='fa fa-building-o'></span>";
                                echo "</div>";                             
                                echo "<div class='widget-data'>";

                                        while ($row_aprt = $stmt->fetch(PDO::FETCH_ASSOC)){
                                                    extract($row_aprt);                                                        

                                                    echo "<div class='widget-int num-count'>{$num_apart}</div>";
                                                    echo "<div class='widget-title'>{$nm_apart} - {$tipo_apart}</div>";
                                                    echo "<div class='widget-subtitle'>Disponivel - {$disponivel}</div>";

                                            } 

                                echo "</div>";                                    
                            echo "</div>";
                        echo "</div>";
    
asked by anonymous 28.10.2017 / 02:56

1 answer

0

In fact there was the following problem: by putting the entire contents of the while loop within a <div class='col-md-2'> , the content did not fit into a single "line" and broke to the next, leaving only a content column (which is expected to do so). So, to solve the problem, just put the content from within the while loop within <div class='col-md-2'> and add the row class to the <div class='widget-data'> div. Changing the code is:

<?php
echo "<div class='widget widget-default widget-item-icon'>";
echo "<div class='widget-item-left'>";
echo "<span class='fa fa-building-o'></span>";
echo "</div>";                   
/***********************************************************
Definindo uma linha para conter os dados do laço while (class row do bootstrap)
***********************************************************/          
echo "<div class='widget-data row'>";

while ($row_aprt = $stmt->fetch(PDO::FETCH_ASSOC)){
    extract($row_aprt);      
    /*****************************************************************
    Conteudo para cada duas colunas
    *****************************************************************/                                                  
    echo "<div class='col-md-2'>";
    echo "<div class='widget-int num-count'>{$num_apart}</div>";
    echo "<div class='widget-title'>{$nm_apart} - {$tipo_apart}</div>";
    echo "<div class='widget-subtitle'>Disponivel - {$disponivel}</div>";
    echo "</div>"; 
}                                    
echo "</div>";
echo "</div>";
?>
    
28.10.2017 / 18:39