qq_42354051
qq_42354051
采纳率0%
2019-03-22 03:21 阅读 332

PHP网站随机增加点击数代码怎么写 有高手帮忙的吗 {.hit}

40
`<td width=30 nowrap align=center class=eng><!--{ ? .hot }--><font color=FF6C68><!--{ / }-->{.hit}</td>
`` 这行代码要怎么写 才能一次浏览随机增加1~10 点击数呢?

以下是 我个人网站公告栏模块所有代码


{*** 目录| board/list.php ***}
<!--{ ? !_pageView }-->
{ # header } {_bdHeader}
<!--{ / }-->

<table width={_bdWidth} align={_bdAlign} cellpadding=0 cellspacing=0><tr><td>

<form name=frmList action="list.php" onsubmit="return chkFormList(this)">
<input type=hidden name=id value="{id}">

<table width=100% border=0 cellpadding=0 cellspacing=0>
<tr>
    <td>

    <table width=100% cellpadding=0 cellspacing=0>
    <tr>
        <td colspan=10 align=right class=eng height=20>
        <!--{ ? !search.word }--> Total {recode.total} Articles, {page.now} of {page.total} Pages
        <!--{ : }-->    Search Mode {page.now} Page
        <!--{ / }-->
        </td>
    </tr>
    <tr>
        <!--{ ? !(_bdField&1) }--><td align=center height=30 background="img/board_bg.gif">{link.chk}<img src="img/board_field_01.gif">{link.end}</td><!--{ / }-->
        <!--{ ? !(_bdField&2) }--><td align=center background="img/board_bg.gif"><img src="img/board_field_02.gif"></td><!--{ / }-->
        <!--{ ? !(_bdField&4) }-->
        <!--{ ? _bdUseSubSpeech }--><td align=center background="img/board_bg.gif">{speechBox}</td><!--{ / }-->
        <td align=center background="img/board_bg.gif"><img src="img/board_field_03.gif"></td>
        <!--{ / }-->
        <!--{ ? !(_bdField&8) }--><td align=center background="img/board_bg.gif"><img src="img/board_field_04.gif"></td><!--{ / }-->
        <!--{ ? !(_bdField&16) }--><td align=center background="img/board_bg.gif"><img src="img/board_field_05.gif"></td><!--{ / }-->
        <!--{ ? !(_bdField&32) }--><td align=center background="img/board_bg.gif"><img src="img/board_field_06.gif"></td><!--{ / }-->
    </tr>
    <!--{ @ list }-->
    <tr height=27 onmouseover=this.style.backgroundColor="#FAFAFA" onmouseout=this.style.backgroundColor=""
    { ? _checked['chk'][.no] }bgcolor=#F7F7F7{ : .notice }bgcolor=#FAFAFA{ / }
    >
        <!--{ ? !(_bdField&1) }-->
        <td width=20 nowrap align=center><input type=checkbox name=sel[] value={.no} {_checked['chk'][.no]}></td>
        <!--{ / }-->
        <!--{ ? !(_bdField&2) }-->
        <td width=50 nowrap align=center class=eng>
        <!--{ ? .notice }--><img src="img/board_notice.gif" align=absmiddle><!--{ : }-->{.num}<!--{ / }-->
        </td>
        <!--{ / }-->
        <!--{ ? !(_bdField&4) }-->
        <!--{ ? _bdUseSubSpeech }--><td width=50 nowrap><!--{ ? .category }-->[{.category}]<!--{ / }--></td><!--{ / }-->
        <td width=100% style="padding-left:10px">
        {.gapReply}<!--{ ? .sub }--><img src="img/board_re.gif" align=absmiddle><!--{ / }-->
        {.link.view}<!--{ ? .notice }--><b style="color:#FE8300"><!--{ / }-->{.subject}{link.end}
        <!--{ ? _bdUseComment && .comment }-->&nbsp;<span class=engs><FONT COLOR="#007FC8">[{.comment}]</FONT></span><!--{ / }-->
        <!--{ ? .secret }--><img src="img/icn_secret.gif" align=absmiddle><!--{ / }-->
        <!--{ ? .new }--><img src="img/board_new.gif" align=absmiddle><!--{ / }-->
        <!--{ ? .hot }--><img src="img/board_hot.gif" align=absmiddle border=0><!--{ / }-->
        {.xx}
        </td>
        <!--{ / }-->
        <!--{ ? !(_bdField&8) }-->
        <td width=100 nowrap align=center>
        <!--{ ? .m_no }--><b><!--{ / }-->{.name}
        </td>
        <!--{ / }-->
        <!--{ ? !(_bdField&16) }-->
        <td width=100 nowrap align=center class=eng>{=substr(.regdt,0,10)}</td>
        <!--{ / }-->
        <!--{ ? !(_bdField&32) }-->
        <td width=30 nowrap align=center class=eng><!--{ ? .hot }--><font color=FF6C68><!--{ / }-->{.hit}</td>
        <!--{ / }-->
    </tr>
    <tr><td colspan=10 height=1 bgcolor=#E0DFDF></td></tr>
    <!--{ / }-->
    </table>

    </td>
</tr>
<tr>
    <td height=40 bgcolor="#F7F7F7">

    <table width=100%>
    <tr>
        <td class=eng>
        {page.navi}
        <!--{ ? link.prev }-->{link.prev}上一页{link.end} <!--{ / }-->
        <!--{ ? link.next }-->{link.next}下一页{link.end}<!--{ / }-->
        </td>
        <td align=right>
        <table cellpadding=0 cellspacing=0>
        <tr>
            <td class=stxt>
            <!--{ ? !(_bdField&8) }-->
            <input type=checkbox name="search[name]" {checked['search']['name']}>名字
            <!--{ / }-->
            <input type=checkbox name="search[subject]" {checked['search']['subject']}>标题
            <input type=checkbox name="search[contents]" {checked['search']['contents']}>内容&nbsp;
            </td>
            <td><input name="search[word]" value="{search.word}" style="background-color:#FFFFFF;border:1px solid #DFDFDF;width:140" required></td>
            <td><a href="javascript:document.frmList.submit()"><img src="img/board_btn_search.gif"></a></td>
            <td><a href="list.php?id={id}"><img src="img/board_btn_cancel.gif"></a></td>
        </tr>
        </table>
        </td>
    </tr>
    </table>

    </td>
</tr>
<tr>
    <td align=center style="padding-top:15">
    <!--{ ? link.delete }-->{link.delete}<img src="img/board_btn_delete.gif">{link.end} <!--{ / }-->
    <!--{ ? !(_bdField&1) }-->{link.viewSel}<img src="img/board_btn_view.gif">{link.end} <!--{ / }-->
    {link.list}<img src="img/board_btn_list.gif">{link.end}
    <!--{ ? link.write }-->{link.write}<img src="img/board_btn_write.gif">{link.end}<!--{ / }-->
    </td>
</tr>
</table><p>

</form>

</td></tr></table>

<!--{ ? !_pageView }-->{_bdFooter} { # footer }<!--{ / }-->
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • meiry meiry 2019-03-22 10:25

    只要在PHP 里面写 用 $hit = rand(1,10) 然后更新到数据库

    点赞 评论 复制链接分享
  • qq_42354051 qq_42354051 2019-03-22 13:51

    在这代码中 要放哪个位置呢?

    <?
    if(!preg_match('/^[a-zA-Z0-9_]*$/',$_GET['id'])) exit;

    @include_once "../conf/bd_".$_GET['id'].".php";
    include "../_header.php";
    include "../lib/page.class.php";
    include "../lib/board.class.php";

    if(class_exists('validation') && method_exists('validation','xssCleanArray')){
    $_GET = validation::xssCleanArray($_GET, array(
    validation::DEFAULT_KEY => 'text',
    'search'=>'disable',
    'subSpeech'=>'html',
    ));

    $_GET['search'] = validation::xssCleanArray($_GET['search'], array(
        validation::DEFAULT_KEY => 'text',
    ));
    

    }

    if (!is_file("../conf/bd_".$_GET[id].".php")) msg("게시판이 존재하지 않습니다",-1);
    if ($bdLvlL && $bdLvlL>$sess['level']) msg("글 목록 권한이 없습니다",-1);

    값이 없는 경우 미리 체크

    if(!$bdListImgCntW) $bdListImgCntW = 5;
    if(!$bdListImgCntH) $bdListImgCntH = 4;
    if($bdSkin == "gallery"){
    if(!$bdListImgSizeW) $bdListImgSizeW = 100;
    if(!$bdListImgSizeH) $bdListImgSizeH = "";
    }else{
    if(!$bdListImgSizeW) $bdListImgSizeW = 45;
    if(!$bdListImgSizeH) $bdListImgSizeH = 45;
    }

    bd class

    $bd = new Board($_GET['page'],$bdPageNum);

    $bd->db = &$db;
    $bd->tpl = &$tpl;
    $bd->cfg = &$cfg;
    if ( file_exists( dirname(__FILE__) . '/../data/skin/' . $cfg['tplSkin'] . '/admin.gif' ) ) $bd->adminicon = 'admin.gif';

    $bd->id = $_GET['id'];
    $bd->subSpeech = $_GET['subSpeech'];
    $bd->search = $_GET['search'];
    $bd->sess = $sess;
    $bd->ici_admin = $ici_admin;
    $bd->date = $_GET['date'];

    $bd->assign(array(
    bdSearchMode => $bdSearchMode,
    bdUseSubSpeech => $bdUseSubSpeech,
    bdSubSpeech => $bdSubSpeech,
    bdSubSpeechTitle => $bdSubSpeechTitle,
    bdLvlR => $bdLvlR,
    bdLvlW => $bdLvlW,
    bdStrlen => $bdStrlen,
    bdNew => $bdNew,
    bdHot => $bdHot,
    ));

    $bd->_list();

    if ($sess){
    $tpl->assign(readonly,array(name => "readonly style='border:0;font-weight:bold'"));
    }

    $bdHeader = stripslashes($bdHeader);
    $bdFooter = stripslashes($bdFooter);

    tpl class

    $tpl->define('list',"board/".$bdSkin."/list.htm");
    if ($templateCache->isEnabled() && $templateCache->checkCacingPage() && $templateCache->checkCondition()) {
    $templateCache->setCache($tpl, 'list');
    }
    if (!$pageView){
    $tpl->print_('list');
    echo "";
    }

    //$db->viewLog();

    ?>

    
    
    点赞 评论 复制链接分享
  • georgechristie 翟码农 2019-03-23 18:03

    如果现在浏览,数据里已经加了1, 那你就找到这个浏览量+1的逻辑代码位置,我现在不知道你那浏览量在数据库表里的列名是啥,我假定是hit_num, 你找到代码里哪里有set hit_num = hit_num + 1的位置(不知道找哪个文件,就尝试所有文件里搜), 然后把+1替换成 + ceil( RAND()*10), 希望能够帮到你。

    点赞 评论 复制链接分享

相关推荐