How to align 2 while result per row

1

How can I make the divs contained in the loop, list 2 per line instead of listing one down from the other

Example to baxco

$sql = "SELECT * FROM aparelhos  ";
$resultado = mysql_query($sql) or die( mysql_error());
while ($row = mysql_fetch_assoc($resultado)) {
$nome = $row['nome'];
<div><?echo $nome?></div>
}

//como normalmente e visualizado
Fulano de Tal
Maria Fulana
Home Simpson
Lisa Simpson

//como queria que visualiza-se
Fulano de Tal             Maria Fulana
Homer Simpson             Lisa Simpson
....                      ....
    
asked by anonymous 19.05.2016 / 03:18

1 answer

3

This is a matter of page formatting. Style! So you should really use CSS .

You can make your <div></div> stand side by side:

div{
  width: 49%;
  border: 1px solid red;
  float: left;
}

If you do not want to occupy the width of <body></body> completely, set a parent element DIV outside the loop while and set the maximum width that you want to occupy with side-by-side printing of data by PHP.

Reference to the float attribute here .

See the CSS in action: fiddle

    
19.05.2016 / 04:33