Looking to display a value from the 1st record's 'post' field which is stored in a MySQL database using PHP. The following div is where the value is to be inserted:
<div id="insert1"><?php echo($r); ?></div>
The PHP (Note using MeekroDB):
<?php
require_once 'meekrodb.2.2.class.php';
DB::$user = 'username';
DB::$password = 'password';
DB::$dbName = 'database';
DB::$host = 'hostname';
// get all entries from database table Microblog;
$results = DB::query("SELECT post FROM MicroBlog");
foreach ($results as $row) {
$id = $row['id'];
// loop through each entry - there's 3
for($i = 0; $i < 3; $i++) {
// if it's the 1st entry (id = 1) then get field 'post'
if ($id == 1) {
$r = $row['post'];
}
}
}
?>
Currently #insert1 is blank. What do I need to change to get it into the div? Please note, I want to keep the for loop, as I'll be adding other if's once I get it running. Thanks.