2016.6.13 php與MySQL資料庫互動之資料庫中的商品資訊展示

來源:互聯網
上載者:User

標籤:

<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">&nbsp;</td>
<td width="124"><font color="FF6501"><img src="../Images/timg.jpg" width="10" height="10">&nbsp;<?php echo $info[pur_name]; ?></font></td>
</tr>
<tr>
<td height="16">&nbsp;</td>
<td><font color="#000000">市場價:</font><font color="FF6501"><?php echo $info[pur_price];?></font></td>
</tr>
<tr>
<td height="16">&nbsp;</td>
<td><font color="#000000">會員價:</font><font color="FF6501"><?php echo $info[pur_mprice];?></font></td>
</tr>
<tr>
<td height="16">&nbsp;</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">&nbsp;</td>
<td width="124"><font color="FF6501"><img src="../Images/timg.jpg" width="10" height="10">&nbsp;<?php echo $info[pur_name]; ?></font></td>
</tr>
<tr>
<td height="16">&nbsp;</td>
<td><font color="#000000">市場價:</font><font color="FF6501"><?php echo $info[pur_price];?></font></td>
</tr>
<tr>
<td height="16">&nbsp;</td>
<td><font color="#000000">會員價:</font><font color="FF6501"><?php echo $info[pur_mprice];?></font></td>
</tr>
<tr>
<td height="16">&nbsp;</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資料庫互動之資料庫中的商品資訊展示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.