I am trying to output values saved in my database into a div field, however the data does not seem to come out, could anyone explain to me why?
<div>
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="Database"; // Database name
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$result=mysql_query("SELECT from `posts`");
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
echo $result[$i];
$i++;
}
?>
</div>
Above is the code I have inside the div tag. So my question why does my echo not work?