欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于PHP+mysql實(shí)現(xiàn)新聞發(fā)布系統(tǒng)的開發(fā)

 更新時(shí)間:2020年08月06日 17:25:28   作者:lk_Empathy  
這篇文章主要介紹了基于PHP+mysql實(shí)現(xiàn)新聞發(fā)布系統(tǒng)的開發(fā),文章通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下 面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

新聞發(fā)布系統(tǒng)

1. 系統(tǒng)簡介

    一個(gè)簡單的新聞系統(tǒng),包含了四個(gè)功能,增刪改查,利用PHP語言,結(jié)合了MySQL數(shù)據(jù)庫,開發(fā)工具用的是Dreamweaver。

2.數(shù)據(jù)庫設(shè)計(jì)

-- 數(shù)據(jù)庫: `newsdb`
CREATE DATABASE IF NOT EXISTS `newsdb` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
USE `newsdb`;
-- 表的結(jié)構(gòu) `news`
CREATE TABLE IF NOT EXISTS `news` (
 `id` int(9) NOT NULL AUTO_INCREMENT,
 `title` varchar(50) NOT NULL,
 `keywords` varchar(50) NOT NULL,
 `author` varchar(16) NOT NULL,
 `addtime` datetime NOT NULL,
 `content` text NOT NULL,
 PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;

首頁

<title>新聞首頁</title>
</head>

<body bgcolor="#CC6666">
<h1 align="center">新聞首頁</h1>
<h3 align="center"><a href="action.html" rel="external nofollow" >新建新聞</a>&nbsp;&nbsp;修改新聞&nbsp; &nbsp; 刪除新聞&nbsp;&nbsp;<a href="ssxw.html" rel="external nofollow" >搜索新聞</a></h3>
</body>

首頁效果圖

這里寫圖片描述

新建新聞

<title>插入新聞</title>
</head>

<body>
<form action="adds.php" method="post">
<h3 align="center">插入新聞</h3>
<table width="300" align="center" border="2">
<tr>
<td>標(biāo)題</td>
<td><input type="text" name="title" /></td>
</tr>
<tr>
<td>關(guān)鍵字</td>
<td><input type="text" name="keywords" /></td>
</tr>
<tr>
<td>作者</td>
<td><input type="text" name="author" /></td>
</tr>
<tr>
<td>內(nèi)容</td>
<td><input type="text" name="content" /></td>
</tr>
<tr >
<td colspan="2" align="center"><input type="submit" value="提交" /></td>
</tr>
</table>
</form>
</body>

新建新聞效果圖

這里寫圖片描述

新建新聞PHP

<title>動(dòng)態(tài)</title>
</head>

<body>
<?php
//加載數(shù)據(jù)庫
//include("mysql.php");
//連接數(shù)據(jù)庫
mysql_connect("localhost","root","") or die("連接失敗");
//設(shè)置編碼格式
mysql_query("set names utf-8");
//選擇數(shù)據(jù)庫
mysql_query("use newsdb") or die("選擇失敗");
//獲取輸入文本
$bt=$_POST['title'];
$gzj=$_POST['keywords'];
$zz=$_POST['author'];
$nn=$_POST['content'];
//獲取系統(tǒng)時(shí)間
/*改時(shí)區(qū)*/
date_default_timezone_set('PRC');
$time=date('Y-m-d h:i:s');
//加入數(shù)據(jù)
$mysql="insert into news values(null,'$bt','$gjz','$zz','$time','$nn')";
$aa=mysql_query($mysql);
//判斷是否插入
if($aa){
  echo "添加成功";}
  else{echo "添加失敗";}


?>
</body>

查詢新聞

<title>搜索新聞</title>
</head>

<body>
<form action="ssxw.php" method="post">
<input type="text" name="ssxw" />
<input type="submit" value="搜索" />
</form>
</body>

查詢新聞效果圖

這里寫圖片描述

查詢新聞PHP

<title>搜索新聞</title>
</head>
<body>
<table width="500" border="2">
<tr>
<th colspan="coL">ID</th>
<th colspan="COL">標(biāo)題</th>
<th colspan="COL">關(guān)鍵字</th>
<th colspan="COL">作者</th>
<th colspan="COL">時(shí)間</th>
<th colspan="COL">內(nèi)容</th>
</tr>
<?php
//載入數(shù)據(jù)庫
include("mysql.php");
//獲取輸入的標(biāo)題
$ssxw=$_POST['ssxw'];
//利用 查詢語句
$sql="select * from news where title like '%$ssxw%'";
//利用索引數(shù)組
$cx=mysql_query($sql);
//遍歷出來
while($sy=mysql_fetch_row($cx)){
  echo "<tr>";
  echo "<td>$sy[0]</td>";
  echo "<td>$sy[1]</td>";
  echo "<td>$sy[2]</td>";
  echo "<td>$sy[3]</td>";
  echo "<td>$sy[4]</td>";
  echo "<td>$sy[5]</td>";
  echo "</tr>";
}
echo "<a href='index.html'>新聞首頁</a>";
?>
</table>
</body>

查詢新聞效果圖

這里寫圖片描述

注意:
1.連接數(shù)據(jù)庫
mysql_connect(“l(fā)ocalhost”,”root”,”“) or die(“連接失敗”);
2.設(shè)置編碼格式
mysql_query(“set names utf-8”);
3.選擇數(shù)據(jù)庫
mysql_query(“use newsdb”) or die(“選擇失敗”);       

在這里先做出增加和查詢兩個(gè)功能,其他功能持續(xù)更新中。。。。。。
期待與你一起學(xué)習(xí)。

到此這篇關(guān)于基于PHP+mysql實(shí)現(xiàn)新聞發(fā)布系統(tǒng)的開發(fā)的文章就介紹到這了,更多相關(guān)PHP+mysql新聞發(fā)布系統(tǒng)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論