我正在尝试在新闻标题旁边显示邮资日期。由于某种原因,他们每个人的日期都是相同的;我没有在同一天发布所有这些,因为每个数据库中的日期都不同。
这是我的代码:
<?php
// Connect to the database
$dbLink = new mysqli('localhost', 'root', 'root', 'olearyinternational');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
// Query for a list of all existing files
$sql = 'SELECT * FROM `posts` order by created desc limit 8';
$result = $dbLink->query($sql);
$date = date('jS F Y', $d);
// Check if it was successfull
if($result) {
// Make sure there are some files in there
if($result->num_rows == 0) {
echo '<p>There are no files in the database</p>';
}
else {
while($row = $result->fetch_assoc()) {
?>
<li class="good-font"><a href="news.php"><?php echo $row['title'] ?><span id = "post_date"><?php echo $date; ?></a></li>
<?php
}
// Close table
echo '</table>';
// Free the result
$result->free();
}
}
else {
echo 'Error! SQL query failed:';
echo "<pre>{$dbLink->error}</pre>";
}
// Close the mysql connection
$dbLink->close();
?>