我最近的项目显示在主页上,weverythnig一直都好,直到今天,我注意到我今天添加的项目没有出现在我的主页上,我不知道为什么这里是我的代码
<?php // Run a select query to get my letest 6 items
// Connect to the MySQL database
session_start();
include "storescripts/connect_to_mysql.php";
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 6");
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$product_name = $row["product_name"];
$price = $row["price"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
$dynamicList .= ' <div id="test"><div id="wrap" align="center"><div id="columns" class="columns_3"><figure><a class="button" href="product.php?id=' . $id . '"><img class="img" style="border:#666 0px solid ;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" border="1" /></a><div class="new_name">' . $product_name . '<br /></div> <div class="new_price"> £' . $price . '<br /></div><div class="new_buy"><a href="product.php?id=' . $id . '"><img src="style/buy.png" /></a></figure></div></div></div>';
} else {
$dynamicList = "We have no products listed in our store yet";
}
mysql_close();
?>
答案 0 :(得分:0)
将限制更改为您想要显示的数量:
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 15");
注意:如果存储的唯一内容是没有时间的日期,那么如果您想要添加实际订单,则还需要按其他内容订购,例如ID:
SELECT * FROM products ORDER BY date_added DESC, id DESC LIMIT 15