I'm trying to figure out the best solution on how to output my html with the php while counting up on a div class.
This is my function that prints news:
function post_news()
{
$post_news = $this->mysql->Query("SELECT * FROM news ORDER BY id DESC LIMIT 4");
while ($news_row = mysqli_fetch_array($post_news))
{
echo "<div class='column1'>
<div class='box'>
<h3>".$news_row['title']."</h3>
<p>".$news_row['content']."</p>
<a href='index.php?p=news&id=".$news_row['id']."' class='button button-small'>Read More</a> </div>
</div>";
}
}
What I am attempting is, where it shows <div class='column1'>
I need it to count upward to class='column4'
. When I attempt For loops or a second While loop I can sometimes get it to count but it always does a new line where I want these blocks to display side by side like normal.
So what is the best way to count up on my div class without it doing a line break after every block?