Tutorial laman web korporat pembangunan PHP untuk memaparkan maklumat berita (1)
Kami telah memperkenalkan cara untuk memaparkan maklumat dalam kandungan sebelumnya, lihat kod:
<?php
require_once('conn.php'); //连接数据库
require_once('functions.php');
$sql = "SELECT * FROM news order by id desc";
$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;}
td{width:200px;height:30px;}
</style>
</head>
<body>
<div class="top"><a href="addne.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>
<?php
if($row['type']==1){
?>
<td>公司新闻</td>
<?php
}else{
?>
<td>公司公告</td>
<?php
}
?>
<td><?php echo $row['title'];?></td>
<td><?php echo msubstr($row['content'],0,15);?></td>
<td>
<a href="modifnew.php?id=<?php echo $row['id'];?>">修改</a>
<a href="delnews.php?id=<?php echo $row['id'];?>">删除</a>
</td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>Kod di atas telah pun memaparkan maklumat berita
fail baharu
<?php
require_once('conn.php'); //连接数据库
require_once('functions.php');
$sql = "SELECT * FROM news order by id desc";
$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;}
td{width:200px;height:30px;}
</style>
</head>
<body>
<div class="top"><a href="addne.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>
<?php
if($row['type']==1){
?>
<td>公司新闻</td>
<?php
}else{
?>
<td>公司公告</td>
<?php
}
?>
<td><?php echo $row['title'];?></td>
<td><?php echo msubstr($row['content'],0,15);?></td>
<td>
<a href="modifnew.php?id=<?php echo $row['id'];?>">修改</a>
<a href="delnews.php?id=<?php echo $row['id'];?>">删除</a>
</td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
Pratonton
Clear
- Cadangan kursus
- Muat turun perisian kursus
Perisian kursus tidak tersedia untuk dimuat turun pada masa ini. Kakitangan sedang menganjurkannya. Sila beri perhatian lebih kepada kursus ini pada masa hadapan~
Pelajar yang telah menonton kursus ini juga sedang belajar
Mari kita bercakap secara ringkas tentang memulakan perniagaan dalam PHP
Pengenalan pantas kepada pembangunan bahagian hadapan web
Pembangunan Tianlongbabu praktikal skala besar bagi rangka kerja MVC versi Mini meniru laman web ensiklopedia perkara yang memalukan
Bermula dengan Pembangunan Praktikal PHP: Penciptaan PHP Pantas [Forum Perniagaan Kecil]
Pengesahan log masuk dan papan mesej klasik
Pengumpulan pengetahuan rangkaian komputer
Mula Pantas Node.JS Versi Penuh
Kursus bahagian hadapan yang paling memahami anda: HTML5/CSS3/ES6/NPM/Vue/...[Asal]
Tulis rangka kerja PHP MVC anda sendiri (40 bab secara mendalam/butiran besar/mesti dibaca untuk pemula untuk maju)
















