Affichage du produit du didacticiel de site Web d'entreprise de développement PHP (1)
Jetons un coup d'œil à la page d'affichage du produit
Le code est le suivant :
<?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>De cette façon, notre affichage du produit a été complété. Nous interrogeons également les informations de la base de données. puis affichez les informations via une boucle, dans la section suivante, nous expliquerons l'effet de la pagination pour l'affichage du produit
nouveau fichier
<?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>
Aperçu
Clear
- Recommandations de cours
- Téléchargement du didacticiel
Le didacticiel n'est pas disponible au téléchargement pour le moment. Le staff est actuellement en train de l'organiser. Veuillez prêter plus d'attention à ce cours à l'avenir ~
Les étudiants qui ont regardé ce cours apprennent également
Parlons brièvement de la création d'une entreprise en PHP
Introduction rapide au développement web front-end
Développement pratique à grande échelle par Tianlongbabu du cadre MVC version Mini imitant le site Web de l'encyclopédie des choses embarrassantes
Premiers pas avec le développement pratique PHP : création rapide de PHP [Small Business Forum]
Vérification de connexion et forum de discussion classique
Collecte de connaissances sur les réseaux informatiques
Démarrage rapide de la version complète de Node.JS
Le cours front-end qui vous comprend le mieux : HTML5/CSS3/ES6/NPM/Vue/...[Original]
Écrivez votre propre framework PHP MVC (40 chapitres en profondeur/gros détails/à lire absolument pour que les débutants progressent)
















