ppypp伦理天堂,91手机在线视频,免费在线观看黄色毛片,夜夜穞天天穞狠狠穞AV美女按摩

聯(lián)系官方銷售客服

1835022288

028-61286886

投訴 已解決 在頁面中獲取input框的值進(jìn)行數(shù)據(jù)庫查詢 4 0
迅睿CMS版本:4.5.1 懸賞:10元

我想在頁面中獲取input框的值進(jìn)行數(shù)據(jù)庫查詢,我在custom.php中寫了查詢方法,需要傳參,但是不知道怎么將input框中的傳入查詢方法。

custom.php中的自定義函數(shù):

function my_recoWord($theme,$level) {
    $sql = "select * from dr_app_mydata_2 where ".$theme1." LIKE CONCAT('%',theme,'%') and level =".$level1;
    echo $sql;
    $rt = \Phpcmf\Service::M()->db->query($sql);
    if ($rt) {
        $rows = $rt->getResultArray();
        if(!$rows){
            echo '暫無推薦';
        }
        foreach ($rows as $t) {
            echo $t['name'] ;
            echo ' ';
        }
    }
}

模板中:

            <label>{function name=my_recoWord param1=input框參數(shù)1 param2=input框參數(shù)2 cache=300}{$t}{/function}</label>
解決方案
  • 增加懸賞(設(shè)置懸賞)金:5元,希望大家給予幫助!
  • 這種思路的話實(shí)現(xiàn)不了這種功能。

    我的建議思路是,需要新建控制器,提交的動作的要通過ajax或者是純url傳遞到控制器中,然后在控制器器里面進(jìn)行數(shù)據(jù)業(yè)務(wù)邏輯處理,然后再返回到模板里面。

  • function postShow(){
            console.log($('#dr_level').val());
            console.log($('#dr_theme').val());
            $.ajax({
            url: "{dr_url('Xiezuowenzhang/html/getData')}",
            type: "GET",
            dataType: "json",
            data: {
                dr_level:$('#dr_level').val(),
                dr_theme:$('#dr_theme').val()
            },
            success: function(index){
                console.log(index);
                if (index.code == 1){
                    $('#postShow1').remove();
                
                    $('#recoword').append('<div id="postShow1">'+index.data+'</div>');
                
                }
                
            },
            error: function(index){
                if (index.code == 0){
                    alert(index.msg);
                    setTimeout(function(){
                        location.reload();
                    },1000);
                }
              
            }
    
        });
    
        return false;
        }
    <div class="form-group" id="recoword">
                            <button onclick="postShow()">查看推薦詞匯</button>
                            <div id="postShow1"></div>
                            <!-- <label>{function name=my_recoWord param1=input框參數(shù)1 param2=input框參數(shù)2 cache=300}{$t}{/function}</label> -->
                        </div>
    public function getData(){
    		
    		$result = \Phpcmf\Service::M()->db->table('app_mydata_2')->select('name')->where('level',$_GET['dr_level'])->where("'".$_GET['dr_theme']."' LIKE CONCAT('%',theme,'%')")->get()->getResultArray();
    
    		for ($i=0; $i < count($result); $i++) { 
    			$data[$i] = $result[$i]['name'];
    		}
    
    		if ($result) {
    			return json_encode([
    				'code' => 1,
    				'msg' => '內(nèi)容獲取成功',
    				'data' => $data
    			]);
    		}else{
    			return json_encode([
    				'code' => 0,
    				'msg' => '內(nèi)容獲取失敗',
    				'data' => ''
    			]);
    		}
    	}
    滿意答案
    短信幣+1
    +10元
    有事加微信13139129987
  • @琉惗:謝謝,已經(jīng)解決問題