php普通用户浏览界面(为方便队友重组代码)

1、代码部分说明

putongmain.php(普通用户浏览商品主界面)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品界面</title>
    <style type="text/css">
        html{font-size:12px;}
        fieldset{width:850px; margin: 0 auto;}
        legend{font-weight:bold; font-size:14px;}
        label{float:left; width:70px; margin-left:10px;}
        .left{margin-left:80px;}
        .input{width:150px;}
        .sousu{margin-left:210px; width:300px}
        .sousubutton{margin-left:20px;}
    </style>
</head>
<body>
<fieldset>
        <legend><font color="blue">商品浏览</font></legend>
        <form  method="post" action="save.php">
        <p>
            <input id="sousu" name="bname" type="text"  class="sousu" />
            <input type="submit" name="sousubutton" value="搜索"  class="sousubutton">
            <a href="gouwuche.php" target="_self" class="sousubutton">查看购物车</a>
        </p>
        </form>

        <table border="0px"cellspacing="20px" cellpadding="5px">
            <?php
            $conn = mysqli_connect("localhost", "root", "123", "db") or die("连接数据库服务器失败!".mysqli_error()); //连接MySQL服务器,选择数据库
            mysqli_query($conn,"set names utf8");                        //设置数据库编码格式utf8
            mysqli_select_db($conn,‘db‘); //选择数据库
            $q = "select * from bookinfo"; //SQL查询语句
            $rs=mysqli_query($conn,$q);
            //$rs = mysqli_query($q, $link); //获取数据集
            while($row = mysqli_fetch_row($rs)){
                echo "<tr><td><img src=‘$row[3]‘/></td><td>$row[1]</td><td>$row[2]</td><td>$row[4]</td><td><a href=‘shoppingchuli.php?ids={$row[1]}‘>加入购物车</a></td></tr>"; //显示数据
            }
            ?>
        </table>
    </fieldset>
</body>
</html>

 

save.php

<?php
/**
 * Created by PhpStorm.
 * User: 米羊
 * Date: 2020/5/28
 * Time: 20:26
 */
$bname=$_POST[‘bname‘];
header("location:sousu.php?bname=$bname ");

sousu.php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>商品界面</title>
    <style type="text/css">
        html{font-size:12px;}
        fieldset{width:850px; margin: 0 auto;}
        legend{font-weight:bold; font-size:14px;}
        label{float:left; width:70px; margin-left:10px;}
        .left{margin-left:80px;}
        .input{width:150px;}
        .sousu{margin-left:210px; width:300px}
        .sousubutton{margin-left:20px;}
    </style>
</head>
<body>
<?php
$bname=$_GET[‘bname‘];
?>
<fieldset>
    <legend><font color="blue">商品搜索</font></legend>
    <p>
        <input id="sousu" name="sousu" type="text"  class="sousu"  value="<?php echo $bname ?>"/>
        <input type="submit" name="sousubutton" value="搜索"  class="sousubutton">
        <a href="gouwuche.php" target="_self" class="sousubutton">查看购物车</a>
    <p/>
<table border="0px"cellspacing="20px" cellpadding="5px">
    <?php
    $bname=$_GET[‘bname‘];
    $conn = mysqli_connect("localhost", "root", "123", "db") or die("连接数据库服务器失败!".mysqli_error()); //连接MySQL服务器,选择数据库
    mysqli_query($conn,"set names utf8");                        //设置数据库编码格式utf8
    mysqli_select_db($conn,‘db‘); //选择数据库
    $q = "select * from bookinfo where bname like ‘%{$bname}%‘"; //SQL查询语句
    $rs=mysqli_query($conn,$q);
    //$rs = mysqli_query($q, $link); //获取数据集
    $row = mysqli_fetch_array($rs);
    echo "<tr><td><img src=‘$row[3]‘/></td><td>$row[1]</td><td>$row[2]</td><td>$row[4]</td><td><a href=‘shoppingchuli.php?ids={$row[1]}‘>加入购物车</a></td></tr>"; //显示数据
    ?>
</table>
</fieldset>
</body>
</html>

 

 

image文件下放置的是书的图片

2、数据库展示

php普通用户浏览界面(为方便队友重组代码)

 

php普通用户浏览界面(为方便队友重组代码)

 

 

 数据库名db,数据表名bookinfo

php普通用户浏览界面(为方便队友重组代码)

 

 sql文件已经发到宿舍群里了

实现效果图

php普通用户浏览界面(为方便队友重组代码)

输如参数,点击搜索

php普通用户浏览界面(为方便队友重组代码)

 

php普通用户浏览界面(为方便队友重组代码)

上一篇:解决 asp.net core swagger nginx 代理服务器转发后,无法访问的问题 Swashbuckle


下一篇:Asp.NET Core Nginx Ocelot ForwardedHeaders X-Forwarded-For