PHP开发企业网站教程之产品展示(一)
下面我们来看下产品展示的页面
代码如下:
<?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>这样我们的产品展示就已经完成了,也是从数据库查询信息,然后通过循环把信息展示,下节我们将讲解给产品展示做一个分页的效果
neue Datei
<?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>
Vorschau
Clear
- Kursempfehlungen
- Kursunterlagen herunterladen
Die Kursunterlagen stehen derzeit nicht zum Download zur Verfügung. Die Mitarbeiter organisieren es derzeit. Bitte schenken Sie diesem Kurs in Zukunft mehr Aufmerksamkeit
Auch Studierende, die diesen Kurs gesehen haben, lernen
Lassen Sie uns kurz über die Gründung eines Unternehmens in PHP sprechen
Kurze Einführung in die Web-Frontend-Entwicklung
Umfangreiche, praktische Tianlongbabu-Entwicklung eines Mini-Version-MVC-Frameworks, das die Enzyklopädie-Website mit peinlichen Dingen imitiert
Erste Schritte mit der praktischen PHP-Entwicklung: Schnelle PHP-Erstellung [Small Business Forum]
Anmeldebestätigung und klassisches Message Board
Wissenssammlung über Computernetzwerke
Schnellstart-Node.JS-Vollversion
Der Frontend-Kurs, der Sie am besten versteht: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Schreiben Sie Ihr eigenes PHP-MVC-Framework (40 Kapitel ausführlich/große Details/Muss gelesen werden, damit Neulinge vorankommen)
















