PHP development corporate website tutorial product display (1)
Let’s take a look at the product display page
The code is as follows:
<?php
require_once('conn.php'); //连接数据库
$sql = "SELECT * from product order by id desc"; //查询user表中的数据
$info = mysql_query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>展示用户列表</title>
<style type="text/css">
.top{height:30px;line-height:30px;float:right;margin-right:15px;}
.top a{color:red;text-decoration:none;}
.cont{width:100%;height:300px;float:left;}
.cont_ct{float:left;}
table{width:100%;border:1px solid #eee;text-align:center;}
th{background:#eee;height:30px;}
td{width:200px;height:70px;}
</style>
</head>
<body>
<div class="top"><a href="addpro.php">添加产品</a></div>
<div class="cont">
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<th>ID</th>
<th>名称</th>
<th>图片</th>
<th>价格</th>
<th>操作</th>
</tr>
<?php
while($row = mysql_fetch_array($info)){
?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['title'];?></td>
<td><img src="../uploads/<?php echo $row['imgname'];?>" width="50" height="50"></td>
<td><?php echo $row['price'];?></td>
<td>
<a href="modifypro.php?id=<?php echo $row['id'];?>">修改</a>
<a href="delproduct.php?id=<?php echo $row['id'];?>">删除</a>
</td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>In this way, our product display has been completed. We also query the information from the database, and then display the information through a loop. , in the next section we will explain the effect of pagination for product display
new file
<?php
require_once('conn.php'); //连接数据库
$sql = "SELECT * from product order by id desc"; //查询user表中的数据
$info = mysql_query($sql);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>展示用户列表</title>
<style type="text/css">
.top{height:30px;line-height:30px;float:right;margin-right:15px;}
.top a{color:red;text-decoration:none;}
.cont{width:100%;height:300px;float:left;}
.cont_ct{float:left;}
table{width:100%;border:1px solid #eee;text-align:center;}
th{background:#eee;height:30px;}
td{width:200px;height:70px;}
</style>
</head>
<body>
<div class="top"><a href="addpro.php">添加产品</a></div>
<div class="cont">
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<th>ID</th>
<th>名称</th>
<th>图片</th>
<th>价格</th>
<th>操作</th>
</tr>
<?php
while($row = mysql_fetch_array($info)){
?>
<tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['title'];?></td>
<td><img src="../uploads/<?php echo $row['imgname'];?>" width="50" height="50"></td>
<td><?php echo $row['price'];?></td>
<td>
<a href="modifypro.php?id=<?php echo $row['id'];?>">修改</a>
<a href="delproduct.php?id=<?php echo $row['id'];?>">删除</a>
</td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















