tp架構怎麼根據傳的參數查詢資料?

來源:互聯網
上載者:User
比如一個搜尋表單根據使用者輸入的值搜尋name欄位下的對應的名字 這個應該怎麼查詢呢?我只會寫這麼一點 tp裡面傳值不知道該怎麼弄 怎麼傳值怎麼接收?
比如這裡的這個action值應該寫什嗎? 我看手冊只有在後台接收資料的 用的是I函數 接收完了怎麼使用呢?
 

後台也不會寫 唯寫了一點
class FirstController extends Controller {    public function qq(){    $qq=new \Model\qqModel();        $qq->field('name');        $info=$qq->select();    $this->assign('info',$info);        $this->display();    }}


我問了問別人他們說應該這樣改
 

public function search(){    $name=I("post.name");    $info=M("qq")->where('name like %'.$name.'%')->select();    var_dump($info);}

這樣試了一下 提示報錯了:1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%% )' at line 1 [ SQL語句 ] : SELECT * FROM `qq` WHERE ( name like %% )




回複討論(解決方案)

fffffffffffffffffffffffffffffffffffffffff

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.