我正在尝试获取最后一个表数据行。我有这个代码:
// Connects to your Database
mysql_connect("*", "*", "*") or die(mysql_error());
mysql_select_db("*") or die(mysql_error());
// Collects data from table
$data = mysql_query("SELECT * FROM ps_product_lang JOIN ps_image ON ps_image.id_product = ps_product_lang.id_product WHERE id_lang = '1' ORDER BY ps_product_lang.id_product DESC LIMIT 16")
or die(mysql_error());
// puts the info into the $info array
$info = mysql_fetch_array( $data );
define('COLS', 6); // number of columns
$col = 0; // number of the last column filled
echo '<tr>'; // start first row
while($info = mysql_fetch_array( $data ))
{ $col++;
if ($col == COLS) // have filled the last row
{ $col = 1;
echo '</tr><tr>'; // start a new one
}
echo '<td width="150" height="150" align="center" class="newprod">';
Print (strtolower (str_replace(" ","-","<a/href='/shop/".$info['id_product'] . "-".$info['link_rewrite'] . ".html'><img/src='http://wearitnewear.com/shop/".$info['id_image'] . "-medium/".$info['link_rewrite'] . ".jpg'></a>")));
echo '<br/>';
Print " ".$info['name'] . " ";
echo '</td>';
}
echo '</tr>'; // end last row
我已将限制设置为 16,但它只从表中提取 15 个条目;最后一个它不会拉出和显示。
所以如果我说有
1
2
3
4
5
它只会显示
1
2
3
4
但我的限制必须设置为 5