• 2016.6.13 php与MySQL数据库交互之数据库中的商品信息展示


    <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>

  • 相关阅读:
    2.27
    string.Format("{0,-50}", "qqqqqqqqqqqq")
    dataGridView
    dataGridView添加列行
    设置拖拽事件,获取拖拽内容
    ,鼠标右键,将ListView的内容存入剪贴板
    winform ListView点击行表头,排序
    Aes加密解密
    C#get ,post HttpClient
    将json格式的string转化为对象
  • 原文地址:https://www.cnblogs.com/hqutcy/p/5582150.html
Copyright © 2020-2023  润新知