标签:数据库 插入信息 mysql web开发 fckeditor
一个资讯网站维护个人内容的实例,添加信息
信息编辑页面
引入编辑器脚本
<script type="text/javascript" src="@{sys:path}fckeditor/fckeditor.js"></script>
<BODY leftMargin=0 topMargin=0 MARGINWIDTH="0" MARGINHEIGHT="0" onload="showFCK()">信息标题及内容编辑器<TABLE class=border cellSpacing=0 cellPadding=0 width="98%" align=center
border=0>
<form action="@{sys:face}@{sys:curPath}blog_add_save.chtml" method="post" id="save">
<TR><TD align=center height=24 noWrap> <b>标 题</b> </TD><td><input name="title" size=98></td></TR>
<TR>
<TD align=center height=24 valign="top" colspan=2>
<textarea name=content style="display:none"></textarea>
<script type="text/javascript">
function showFCK()
{
var sBasePath = "@{sys:path}fckeditor/";
var oFCKeditor = new FCKeditor( 'content' ) ;
oFCKeditor.BasePath = sBasePath ;
oFCKeditor.Height = 600 ;
oFCKeditor.Value = '' ;
oFCKeditor.ReplaceTextarea() ;
}
</script>
</TD>
</TR>
<input type="hidden" value="@{pPage:n}" name="n">
</form>
<tr>
<td height="30" colspan=2 align=center><a href="javascript:doSubmit();" id=MySubmit1>[提交]</a><div id=MyWait1 style="display:none">正在提交,请稍候...</div></td>
</tr>
</TABLE>提交信息的脚本function doSubmit()
{
var saves = document.forms['save'];
if(saves['title'].value=="")
{alert("标题不能空!");saves['title'].focus();return;}
var oEditor = FCKeditorAPI.GetInstance('content');
var oDOM = oEditor.EditorDocument;
var des;
if(document.all) // If Internet Explorer.
des = oEditor.EditorDocument.body.innerText;
else{ // If Gecko.
var r = oDOM.createRange();
r.selectNodeContents(oDOM.body);
des = r.toString();
}
if(des=="")
{alert("内容不能空!");return;}
saves.submit();
MySubmit.style.display="none";
MyWait.style.display="block";
MySubmit1.style.display="none";
MyWait1.style.display="block";
}显示如图信息保存的页面
判断登录
<if x="@{session:user_id}" else=1>
<script>alert("请先登录!");top.location.href="@{sys:path}";</script>
<we>...</we>
</if>取ID
<bag id=doc><we name=we_id>@{sn:favorite}</we></bag>
<if x="@{doc:we_id}">
<we>
<esql module=base id=pk commit=true>Select max(WE_ID) as favorite_id from favorite_base</esql>
<bag id=doc><we name=we_id>@{sn:favorite=@{pk:favorite_id}}</we></bag>
</we>
</if>中文分词
<!-- 分词 --> <call>doc2words</call> ... <chtml file="htm/doc2words.htm" onlycall id=doc2words />插入信息
<ESql module=base act=edit commit=true>
Insert Into favorite_base(we_id,title,words,content,words_content)
Values(
@{doc:we_id:int},
@{pPage:title:string},
@{pPage:words:string},
@{pPage:content:memo},
@{pPage:words_content:memo}
)
</ESql>
<bag id=pPage><we name=content1>@{intLeft:@{pPage:content1}(580)}</we></bag>
<ESql module=base act=edit>
Insert Into favorite_user(f_id,author,tree_id,ondate,memo)
Values(
'@{doc:we_id}',
'@{session:user_id}',
'@{pPage:n}',
'@{sys:date}',
@{pPage:content1:memo}
)
</ESql>返回列表页<to>@{sys:path}@{sys:curPath}blogs.html?n=@{pPage:n}&myid=@{session:user_id}</to>完整的网页代码<html>
<chtml>
<if x="@{session:user_id}" else=1>
<script>alert("请先登录!");top.location.href="@{sys:path}";</script>
<we>
<bag id=doc><we name=we_id>@{sn:favorite}</we></bag>
<if x="@{doc:we_id}">
<we>
<esql module=base id=pk commit=true>Select max(WE_ID) as favorite_id from favorite_base</esql>
<bag id=doc><we name=we_id>@{sn:favorite=@{pk:favorite_id}}</we></bag>
</we>
</if>
<!-- 分词 -->
<call>doc2words</call>
<ESql module=base act=edit commit=true>
Insert Into favorite_base(we_id,title,words,content,words_content)
Values(
@{doc:we_id:int},
@{pPage:title:string},
@{pPage:words:string},
@{pPage:content:memo},
@{pPage:words_content:memo}
)
</ESql>
<bag id=pPage><we name=content1>@{intLeft:@{pPage:content1}(580)}</we></bag>
<ESql module=base act=edit>
Insert Into favorite_user(f_id,author,tree_id,ondate,memo)
Values(
'@{doc:we_id}',
'@{session:user_id}',
'@{pPage:n}',
'@{sys:date}',
@{pPage:content1:memo}
)
</ESql>
<to>@{sys:path}@{sys:curPath}blogs.html?n=@{pPage:n}&myid=@{session:user_id}</to>
</we>
</if>
</chtml>
</html>
<chtml file="htm/doc2words.htm" onlycall id=doc2words />保存后的列表效果
轻开平台资源下载及说明
平台免费下载:http://download.csdn.net/detail/tx18/8381859
最新开发手册下载:http://download.csdn.net/detail/tx18/8411089
开发实例:轻开B2C电子商务网站,免费下载:http://download.csdn.net/detail/tx18/8318585
轻开平台会不定期升级为大家提供更多强大而Easy的功能,请留意最新的开发手册
标签:数据库 插入信息 mysql web开发 fckeditor
原文地址:http://blog.csdn.net/tx18/article/details/43559655