我有一个列出所有产品的产品列表页面。目前我列出了很多产品,我想首先显示至少15个,以使其“加载友好”。我想在页面下方输入一个下一个按钮,单击该按钮将显示列表中的更多产品。如果没有更多产品要显示(或者所有产品都已显示),则Next按钮将不再显示。我的代码可以在下面吗?
<?php
include "storescripts/connect_to_mysql.php";
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 15");
$productCount = mysql_num_rows($sql); // count the output amount
$i = 0;
$dynamicList = '<table border="1" bordercolor="#d6d6d6" cellpadding="10"
cellspacing="0" style="border-collapse:collapse;">';
while($row = mysql_fetch_array($sql)){
$id = $row["id"];
$brand = $row["brand"];
$product_name = $row["product_name"];
$pdetails = $row["pdetails"];
$details = $row["details"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
if ($i % 3 == 0) { // if $i is divisible by our target number (in
this case "3")
$dynamicList .= '<tr><td><a href="product.php?id=' . $id . '"
title="' . $pdetails . '"><img src="inventory_images/' . $id . '.jpg" width="295"
border="0" ><br><br>' . $brand . '<br>' . $product_name . '</a></td>';
} else {
$dynamicList .= '<td><a href="product.php?id=' . $id . '" title="' .
$pdetails . '"><img src="inventory_images/' . $id . '.jpg" width="295" border="0" >
<br><br>' . $brand . '<br>' . $product_name . '</a></td>';
}
$i++;
}
$dynamicList .= '</tr></table>';
?>
<!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 content="text/html; charset=iso-8859-1" http-equiv="Content-Type"/>
<title>Product List</title>
<link rel="shortcut icon" href="icon.png" />
<link rel="icon" href="icon.png" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="../rustansstyle.css" />
</head>
<body marginwidth="0" marginheight="0" leftmargin="0" rightmargin="0" topmargin="0"
bottommargin="0">
<center>
<div id="mainWrapper">
<?php include_once("header.php");?>
<div id="pagetitle_skincare" style="margin-top:0px;"></div>
<table border="0">
<tr>
<td valign="top" width="230">
<div id="product_category">
<li><a href="#">Dresses</a></li>
<li><a href="#">Short Dresses</a></li>
<li><a href="#">Maxi Dresses</a></li>
<li><a href="#">Cocktail Dresses</a></li>
</div>
</td>
<td valign="top" width="950">
<div class="preview_inner"><?php echo $dynamicList; ?></div></td>
</tr>
</table>
<br />
<br /><?php include_once("footer.php");?>
</div>
</center>
如果是,请帮我创建一个设备友好的(电脑,iPhone,iPad等)。提前谢谢。