I cannot display data populated in column-separated Divs

Asked

Viewed 23 times

0

I want to display data from a table by Divs with columns of specific size for each of them, but when I load the information, it brings them all in the same column, I don’t want to use table tags to format them. Look how it’s turning out here.

inserir a descrição da imagem aqui

                            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>";
  • Define a div with the Bootstrap Row class to behave the others, within this div create the others with the class col-Md-2 bringing your information

  • Actually had already put a div with a Row class, even with it is still presenting this small formatting flaw

1 answer

0

In fact there was the following problem: by placing all the contents of the while loop inside a <div class='col-md-2'>, the contents did not fit in a single "line" and broke into the next, leaving only a column of content (which is what is expected when doing this). So to solve the problem just put the contents inside the while loop inside <div class='col-md-2'> and add the class row in the div <div class='widget-data'>. 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>";
?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.