基于PHP+mysql實(shí)現(xiàn)新聞發(fā)布系統(tǒng)的開(kāi)發(fā)
新聞發(fā)布系統(tǒng)
1. 系統(tǒng)簡(jiǎn)介
一個(gè)簡(jiǎn)單的新聞系統(tǒng),包含了四個(gè)功能,增刪改查,利用PHP語(yǔ)言,結(jié)合了MySQL數(shù)據(jù)庫(kù),開(kāi)發(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://m.lshqa.cn/bcjs/action.html' rel='external nofollow' >新建新聞</a> 修改新聞 刪除新聞 <a href='http://m.lshqa.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)的開(kāi)發(fā)的文章就介紹到這了,更多相關(guān)PHP+mysql新聞發(fā)布系統(tǒng)內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. XML 取得元素的字符數(shù)據(jù)2. 利用CSS3新特性創(chuàng)建透明邊框三角3. XML入門的常見(jiàn)問(wèn)題(三)4. Vue3獲取DOM節(jié)點(diǎn)的3種方式實(shí)例5. 多級(jí)聯(lián)動(dòng)下拉選擇框,動(dòng)態(tài)獲取下一級(jí)6. 不要在HTML中濫用div7. CSS3實(shí)例分享之多重背景的實(shí)現(xiàn)(Multiple backgrounds)8. vue實(shí)現(xiàn)將自己網(wǎng)站(h5鏈接)分享到微信中形成小卡片的超詳細(xì)教程9. 前端html+css實(shí)現(xiàn)動(dòng)態(tài)生日快樂(lè)代碼10. 詳解CSS偽元素的妙用單標(biāo)簽之美
