標籤:
<table width="550" border="2" align="center" cellpadding="0" cellspacing="0">
推薦品牌
<tr>
<td width="555" height="110"><table width="530" height="110" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="265"> //這裡開始是第一個商品
<?php
mysql_select_db("member");
mysql_query("set character set utf8");
mysql_query("set name utf8");
$result=mysql_query("SELECT * FROM `purchasemessages`where pur_tuijian=1 order by pur_id desc limit 0,1");
//pur_tuijian=1是限制條件,這個非常重要,和desc(降序),limit 0,1是取出表中的第一條記錄
$info=mysql_fetch_array($result);
if($info==false){
echo "本站暫無商品!";
}
else{
?>
<table width="270" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="130" rowspan="5"><div align="center">
<?php if(trim($info[pur_pic]=="")){
echo "暫無圖片";
}
else{
?>
<img src="<?php echo $info[pur_pic];?>" width="80" height="80" border="0">
<?php
}
?>
</div>
</td>
<td width="11" height="16"> </td>
<td width="124"><font color="FF6501"><img src="../Images/timg.jpg" width="10" height="10"> <?php echo $info[pur_name]; ?></font></td>
</tr>
<tr>
<td height="16"> </td>
<td><font color="#000000">市場價:</font><font color="FF6501"><?php echo $info[pur_price];?></font></td>
</tr>
<tr>
<td height="16"> </td>
<td><font color="#000000">會員價:</font><font color="FF6501"><?php echo $info[pur_mprice];?></font></td>
</tr>
<tr>
<td height="16"> </td>
<td><font color="#000000">剩餘數量:</font><font color="13589B">
<?php
if ($info[pur_total]>0) {
echo $info[pur_total];
}
else{
echo "已售完";
}
?>
</font></td>
</tr>
<tr>
<td height="30" colspan="2"><a href="lookinfo.php?id=<?php echo $info[pur_id];?>"><img src="../Images/28f06ff99e1fecd67e222249e6c04ded.png" width="34" height="15" border="0"></a><a href="addgouwuche.php?id=<?php echo $info[pur_id];?>"><img src="../Images/shopping.png" width="50" height="15" border="0"></a></td>
</tr>
</table>
<?php
}
?>
</td> //第一個商品資訊顯示結束
<td width="265"> //從這裡開始是第二個商品
<?php
mysql_select_db("member");
mysql_query("set character set utf8");
mysql_query("set name utf8");
$result=mysql_query("SELECT * FROM `purchasemessages`where pur_tuijian=2 order by pur_id desc limit 0,1");
//這裡pur_tuijian=2 是限制條件,非常重要;limit 0,1,指取出第一條記錄;如果在表中pur_tuijian都等於1,則這裡的limit可以為(1,1),即取表中pur_tuijian=1的第二條記錄
$info=mysql_fetch_array($result);
if($info==true){
?>
<table width="270" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="130" rowspan="5"><div align="center">
<?php if(trim($info[pur_pic]=="")){
echo "暫無圖片";
}
else{
?>
<img src="<?php echo $info[pur_pic];?>" width="80" height="80" border="0">
<?php
}
?>
</div>
</td>
<td width="11" height="16"> </td>
<td width="124"><font color="FF6501"><img src="../Images/timg.jpg" width="10" height="10"> <?php echo $info[pur_name]; ?></font></td>
</tr>
<tr>
<td height="16"> </td>
<td><font color="#000000">市場價:</font><font color="FF6501"><?php echo $info[pur_price];?></font></td>
</tr>
<tr>
<td height="16"> </td>
<td><font color="#000000">會員價:</font><font color="FF6501"><?php echo $info[pur_mprice];?></font></td>
</tr>
<tr>
<td height="16"> </td>
<td><font color="#000000">剩餘數量:</font><font color="13589B">
<?php
if ($info[pur_total]>0) {
echo $info[pur_total];
}
else{
echo "已售完";
}
?>
</font></td>
</tr>
<tr>
<td height="30" colspan="2"><a href="lookinfo.php?id=<?php echo $info[pur_id];?>"><img src="../Images/28f06ff99e1fecd67e222249e6c04ded.png" width="34" height="15" border="0"></a><a href="addgouwuche.php?id=<?php echo $info[pur_id];?>"><img src="../Images/shopping.png" width="50" height="15" border="0"></a></td>
</tr>
</table>
<?php
}
?>
</td> //第二個商品資訊顯示結束
</tr>
</table>
</td>
</tr>
<tr>
<td height="10" background=""></td>
</tr>
</table>
2016.6.13 php與MySQL資料庫互動之資料庫中的商品資訊展示