基于PHP+mysql實(shí)現(xiàn)新聞發(fā)布系統(tǒng)的開發(fā)
新聞發(fā)布系統(tǒng)
1. 系統(tǒng)簡(jiǎn)介
一個(gè)簡(jiǎn)單的新聞系統(tǒng),包含了四個(gè)功能,增刪改查,利用PHP語(yǔ)言,結(jié)合了MySQL數(shù)據(jù)庫(kù),開發(fā)工具用的是Dreamweaver。
2.數(shù)據(jù)庫(kù)設(shè)計(jì)
-- 數(shù)據(jù)庫(kù): `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 ;
首頁(yè)
<title>新聞首頁(yè)</title></head><body bgcolor='#CC6666'><h1 align='center'>新聞首頁(yè)</h1><h3 align='center'><a href='http://www.aoyou183.cn/bcjs/action.html' rel='external nofollow' >新建新聞</a> 修改新聞 刪除新聞 <a href='http://www.aoyou183.cn/bcjs/ssxw.html' rel='external nofollow' >搜索新聞</a></h3></body>
首頁(yè)效果圖
新建新聞
<title>插入新聞</title></head><body><form action='adds.php' method='post'><h3 align='center'>插入新聞</h3><table 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ù)庫(kù)//include('mysql.php');//連接數(shù)據(jù)庫(kù)mysql_connect('localhost','root','') or die('連接失敗');//設(shè)置編碼格式mysql_query('set names utf-8');//選擇數(shù)據(jù)庫(kù)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 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ù)庫(kù)include('mysql.php');//獲取輸入的標(biāo)題$ssxw=$_POST[’ssxw’];//利用 查詢語(yǔ)句$sql='select * from news where title like ’%$ssxw%’';//利用索引數(shù)組$cx=mysql_query($sql);//遍歷出來(lái)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’>新聞首頁(yè)</a>';?></table></body>
查詢新聞效果圖
注意:1.連接數(shù)據(jù)庫(kù)mysql_connect(“l(fā)ocalhost”,”root”,”“) or die(“連接失敗”);2.設(shè)置編碼格式mysql_query(“set names utf-8”);3.選擇數(shù)據(jù)庫(kù)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)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. python全棧開發(fā)語(yǔ)法總結(jié)2. Python調(diào)用接口合并Excel表代碼實(shí)例3. Python如何批量生成和調(diào)用變量4. python b站視頻下載的五種版本5. ajax動(dòng)態(tài)加載json數(shù)據(jù)并詳細(xì)解析6. 通過CSS數(shù)學(xué)函數(shù)實(shí)現(xiàn)動(dòng)畫特效7. Python快速將ppt制作成配音視頻課件的操作方法8. ASP.Net Core(C#)創(chuàng)建Web站點(diǎn)的實(shí)現(xiàn)9. ASP.Net Core對(duì)USB攝像頭進(jìn)行截圖10. 如何在Python項(xiàng)目中引入日志
