Reputation: 83
I am trying to align to divs side by side dynamically so it will look something like this...
Instead I am getting something like this...
Code...
<body>
<div class="container">
<?php
$sql = "SELECT id, name, price FROM tracylynn";
$result = $db->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<div id="item">';
echo "test";
echo '<div>';
}
}
?>
</div>
</body>
.container {
width: 200px;
margin: 0 auto;
}
.container div{
border: 1px solid black;
float: left;
margin: 10px auto;
}
Upvotes: 0
Views: 827
Reputation: 1763
You are not closing the div tag
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo '<div id="item">';
echo "test";
echo '</div>'; //here
}
}
Upvotes: 4