本帖最后由 风清扬丶 于 2013-5-24 21:57 编辑
:问题如图
代码如下:
inc.php:
<?php
if(!defined('IN_DISCUZ')){
exit('Access Denied');
}
if(empty($_G['uid']))
{
showmessage('抱歉,为了保障网站的良好运行 和会员的权益,请注册后再使用本功能,为您带来的不便深表歉意','member.php?mod=register');
}
if($_POST['submit'])
{
$query=DB::query("INSERT INTO ".DB::table('challenge')."(id,uid,username,title,content,lasttime)
VALUES ('','$_G[uid]','$_G[username]',".intval($_POST[title]).",".intval($_POST[content]).",now())");
showmessage('发表成功',NULL);
}
$query1=DB::query("SELECT * FROM ".DB::table('challenge')." order by id desc ");
$row=DB::fetch($query1);//循环函数,根据返回的值生成数组,并在下面循环引用
/*function htmtocode($content)
{
$content = str_replace("\n", "<br>", str_replace(" ", " ", $content));
return $content;
}
*/
$num = DB::result_first("SELECT COUNT(*) FROM ".DB::table('challenge')." WHERE uid='$_G[uid]'");//mysql_result为取得结果数据
$page = $_G['page'] > 10 ? 1 : $_G['page'];
$start_limit = ($page - 1) * 10;
$multipage = multi($num, 10, $page, "plugin.php?id=challenge&mod={$_GET[mod]}");
include template('challenge:challenge');
?>
模版HTM:
{subtemplate common/header}
<link type="text/css" rel="stylesheet" href="source/plugin/down_love/template/extend_common.css" />
<div id="ct" class="wp cl"><!--定义页面导航 -->
<div class="mn">
<div class="bm">
<ul class="tb cl">
<li<!--{if empty($_GET[mod])}--> class="current"<!--{/if}-->><a href="plugin.php?id=challenge"></a></li>
<li<!--{if $_GET[mod] == 'ask_challenge'}--> class="current"<!--{/if}-->><a href="plugin.php?id=challenge&mod=first_challenge"></a></li>
<li<!--{if $_GET[mod] == 'add_challenge'}--> class="current"<!--{/if}-->><a href="plugin.php?id=moodwall&mod=add_challenge"></a></li>
</ul>
<!--{if empty($_GET[mod])}-->
<div class="content" style="background:url(source/plugin/moodwall/template/images/wall.gif);">
<div id="contentarea">
<!--{loop $row $challenge}-->
<table width=500 border="0" cellpadding="5" cellspacing="1" bgcolor="#add3ef">
<tr bgcolor="#eff3ff">
<td>战书:$challenge[title] 挑战者:$challenge[username]</td>
</tr>
<tr bgColor="#ffffff">
<td>内容:$challenge[content]</td>
</tr>
</table>
<!--{/loop}-->
<!--{if !empty($multipage)}-->
<table>
<tr>
<td>$multipage</td>
</tr>
<!--{/if}-->
<!--{else}-->
<tr>
<td colspan="5" align="center">{lang moodwall:moodwall_htm_44}</td>
</tr>
</table>
<!--{elseif $_GET[mod] == 'add_challenge'}-->
<SCRIPT language=javascript>
function CheckPost()
{
if (myform.user.value=="")
{
alert("请填写用户名");
myform.user.focus();
return false;
}
if (myform.title.value.length<5)
{
alert("标题不能少于5个字符");
myform.title.focus();
return false;
}
if (myform.content.value=="")
alert("必须要填写留言内容");
myform.content.focus();
return false;
}
}
</SCRIPT>
<form action="plugin.php?id=challenge:challenge" method="post" name="myform">
挑战者:<input type="text" size="10" name="user" /><br>
战书:<input type="text" name="title" /><br/>
内容:<textarea name="content" cols="60" rows="9"></textarea><br/>
<input type="submit" name="submit" value="下战书"/>
</form>
<!--{elseif $_GET[mod] == 'first_challenge'}-->
<!--{/if}-->
<!--{/if}-->
</div>
<!--{/if}-->
{subtemplate common/footer}
求解答,谢谢
|