欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

这是我在做的一个系统中的新闻增加程序,可以上传图片,也可以输入绝对大于4K的内容(在textarea中),...

程序员文章站 2022-04-15 12:33:46
...

程序|上传|上传图片

/*******所用到的表结构********
DROP TABLE IF EXISTS index_news;
CREATE TABLE index_news (
news_id bigint(20) NOT NULL auto_increment,
news_date date DEFAULT '0000-00-00' NOT NULL,
news_title varchar(100) NOT NULL,
news_content text,
news_link varchar(100),
is_new char(1) DEFAULT '1',
picture_id int(11),
picture_side char(1) DEFAULT '1',
news_show char(1) DEFAULT '1',
PRIMARY KEY (news_id),
KEY id (news_id)
);
DROP TABLE IF EXISTS picture;
CREATE TABLE picture (
id int(11) NOT NULL auto_increment,
picture blob NOT NULL,
picture_type varchar(50) NOT NULL,
PRIMARY KEY (id),
UNIQUE id (id)
);
**********************/
require("../include/date.inc.php3");
require("../include/config.inc.php3");
?>




修改首页新闻信息




if ($add){
$date=input2date($news_date);
//echo $picture . " ". filesize($picture);
//if ($is_new!="0") $is_new="1" ;
//if ($news_show!="0") $news_show="1";
//if ($picture_side!="2") $picture_side="1";
if ($picture!="none"){
$pic_data = addslashes(fread($fp=fopen($picture,"r"), filesize($picture)));
$i_str="insert into picture (picture,picture_type) values ('$pic_data','$picture_type')";
//$rs->open($i_str);
$result=mysql_query($i_str,$dbconnect);
$picture_id=mysql_insert_id();
fclose($fp);
unlink($picture);
}
else{
$picture_id=0 ;
}
$i_str="insert into index_news (news_date,news_title,news_content,news_link,picture_id,is_new,picture_side,news_show) values ";
$i_str.="('$date','$news_title','$news_content','$news_link','$picture_id','$is_new','$picture_side','$news_show') ";

if (mysql_query($i_str,$dbconnect)) echo "已添加!";

}













































增加新闻信息

新闻标题:

新闻内容:

新闻日期:

(日期请按照2000-01-02格式输入)
新闻链接:

是否最新:

新闻图片:

图片位置:

是否显示: