I'm trying to get specific content from every single row in my MySQL database inside a div, however it only shows content from the row with the highest id value.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$query = "SELECT * FROM articles ORDER BY id";
$result = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($result);
while($row = mysql_fetch_array($result))
{
$title = $row['title'];
$summary = $row['summary'];
}
?>
<div class="content">
<h2 class="titlecss"><?php echo ($title)?></h2>
<p class="customfont"><?php echo ($summary)?></p>
</div>
Could anyone explain what I'm doing wrong here? I've been browsing the internet for 2 hours but can't seem to find anything...