有没有办法让 foreach 首先显示最新内容(降序 ID)?我试过找到,但我无法让它工作。
<?php
include_once('includes/connection.php');
include_once('includes/deal.php');
$deal = new Deal;
$deals = $deal->fetch_all();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>GameDeals</title>
<link rel="shortcut icon" type="image/x-icon" href="assets/favicon.png">
<link rel="stylesheet" href="assets/deals.css" />
</head>
<body>
<div class="container">
<!-- START GAMEDEALS -->
<?php foreach ($deals as $deal) { ?>
<div class="deal-info">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100">ID: <?php echo $deal['deal_id']; ?></td>
<td width="500"><?php echo $deal['deal_title']; ?></td>
<td width="200">TS: <?php echo $deal['deal_timestamp']; ?></td>
</tr>
</table>
</div>
<div class="deal-content">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100"><img src="<?php echo $deal['deal_imageurl']; ?>" width="100" height="100" /></td>
<td width="400"><?php echo $deal['deal_content']; ?></td>
<td>
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>Regular Price: <?php echo $deal['deal_normalprice']; ?></td>
</tr>
<tr>
<td>Offer Price: <?php echo $deal['deal_offerprice']; ?></td>
</tr>
<tr>
<td>Off: <?php echo $deal['deal_percent']; ?></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="deal-ref">
<table width="800" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="500">URL: <?php echo $deal['deal_url']; ?></td>
<td width="300">ENDS: <?php echo $deal['deal_expire']; ?></td>
</tr>
</table>
</div>
<?php } ?>
<!-- END GAMEDEALS -->
</div>
</body>
</html>
提前致谢!
更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.更多文本.