php+mysql简易新闻发布系统

上传人:101****457 文档编号:112221168 上传时间:2019-11-05 格式:DOCX 页数:5 大小:15.63KB
返回 下载 相关 举报
php+mysql简易新闻发布系统_第1页
第1页 / 共5页
php+mysql简易新闻发布系统_第2页
第2页 / 共5页
php+mysql简易新闻发布系统_第3页
第3页 / 共5页
php+mysql简易新闻发布系统_第4页
第4页 / 共5页
php+mysql简易新闻发布系统_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《php+mysql简易新闻发布系统》由会员分享,可在线阅读,更多相关《php+mysql简易新闻发布系统(5页珍藏版)》请在金锄头文库上搜索。

1、新闻列表显示(List.php)显示详细的新闻内容(View.php)添加新闻(news_add.html news_add.php)/connect.php连接到数据库/List.php ?phpinclude connect.php; $page=$_GETpage+0;$page=$page$total_page?$total_page:$page;$offset=($page-1)*$page_size;$query=SELECT * from news ORDER by id desc Limit $offset,$page_size;/第一个参数指定第一个返回记录行的偏移量,第二个

2、参数指定返回记录行的最大数目$result=mysql_query($query,$conn);while($row=mysql_fetch_array($result)echo ;echo ; echo ; echo ; echo .$rowtitle.;echo ;echo ;echo .$rowauthor.;echo ;echo ;echo .$rowdate.;echo ;echo ;echo 修改信息; echo ;echo ; echo ;$prev_page=$page-1;$next_page=$page+1;if ($page=1)echo 首页|;elseecho 首页|

3、;if($prev_page1)echo 上一页|;elseecho 上一页|; if ($next_page$total_page)echo 下一页|;elseecho a href=$_SERVERPHP_SELF?page=$next_page下一页|; if ($page=$total_page) echo 最后一页n;elseecho 最后一页; ? 发布信息/View.php?php echo ;$i=0;while ($i$rows=mysql_num_rows($result)echo ;echo ;echo .$rowtitle.;echo ;echo ;echo ;echo

4、 ;echo 作者:.$rowauthor.发表时间.$rowtime;echo ;echo ;echo ;echo ;echo .$rowcontent.;echo ;echo ;$i+;echo ;? 返回列表/news_add.html新闻录入新闻录入界面 标题 作者 内容 /news_add.php?php $conn=mysql_connect(localhost,root,)or die(mysql_error().failed to connect to database!); /连接数据库; $db = mysql_select_db(news1,$conn); $title=

5、$_POSTtitle; $author=$_POSTauthor; $content=$_POSTcontent; $date=date(y-m-d H:i); if(!$title|!$author|!$content) echo You have not entered all the required details.; exit; if(!get_magic_quotes_gpc() $title=addslashes($title); $author=addslashes($author); $content=addslashes($content); if(mysqli_conn

6、ect_errno()echoError: Could not connect to database.Please try again later.;exit;$query=INSERT into news (title,author,content,date)values($title,$author,$content,$date);$result=mysql_query($query,$conn);if($result)echo mysql_affected_rows(). row(s) insert into database.;elseecho An error has occurred.The item was not added.;mysql_close($conn);echo 返回列表;?

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号