基于PHP+mysql實現(xiàn)新聞發(fā)布系統(tǒng)的開發(fā)
新聞發(fā)布系統(tǒng)
1. 系統(tǒng)簡介
一個簡單的新聞系統(tǒng),包含了四個功能,增刪改查,利用PHP語言,結(jié)合了MySQL數(shù)據(jù)庫,開發(fā)工具用的是Dreamweaver。
2.數(shù)據(jù)庫設(shè)計
-- 數(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='http://www.intensediesel.com/bcjs/action.html' rel='external nofollow' >新建新聞</a> 修改新聞 刪除新聞 <a href='http://www.intensediesel.com/bcjs/ssxw.html' rel='external nofollow' >搜索新聞</a></h3></body>
首頁效果圖
新建新聞
<title>插入新聞</title></head><body><form action='adds.php' method='post'><h3 align='center'>插入新聞</h3><table border='2'><tr><td>標題</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>動態(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)時間/*改時區(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'>標題</th><th colspan='COL'>關(guān)鍵字</th><th colspan='COL'>作者</th><th colspan='COL'>時間</th><th colspan='COL'>內(nèi)容</th></tr><?php//載入數(shù)據(jù)庫include('mysql.php');//獲取輸入的標題$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(“選擇失敗”);
在這里先做出增加和查詢兩個功能,其他功能持續(xù)更新中。。。。。。期待與你一起學習。
到此這篇關(guān)于基于PHP+mysql實現(xiàn)新聞發(fā)布系統(tǒng)的開發(fā)的文章就介紹到這了,更多相關(guān)PHP+mysql新聞發(fā)布系統(tǒng)內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. 使用 kind 和 Docker 啟動本地的 Kubernetes環(huán)境2. idea設(shè)置自動導入依賴的方法步驟3. 解決python中import文件夾下面py文件報錯問題4. XML入門精解之結(jié)構(gòu)與語法5. ASP基礎(chǔ)入門第八篇(ASP內(nèi)建對象Application和Session)6. IntelliJ IDEA設(shè)置編碼格式的方法7. IntelliJ IDEA設(shè)置默認瀏覽器的方法8. idea自定義快捷鍵的方法步驟9. IntelliJ IDEA設(shè)置條件斷點的方法步驟10. Idea如何去除Mapper警告方法解析
