Home > Backend Development > PHP Tutorial > How does tp query data based on the passed parameters?

How does tp query data based on the passed parameters?

WBOY
Release: 2016-07-06 13:53:33
Original
977 people have browsed it

For example, a search form searches for the corresponding name under the name field based on the id value entered by the user. How should this be queried? I will only write this little bit. I don’t know how to pass the value in tp. How to pass the value and how to receive it?

<code>        $qq->field('name');
        $info=$qq->select();
        $this->assign('info',$info);
        $this->display();</code>
Copy after login
Copy after login

Reply content:

For example, a search form searches for the corresponding name under the name field based on the id value entered by the user. How should this be queried? I will only write this little bit. I don’t know how to pass the value in tp. How to pass the value and how to receive it?

<code>        $qq->field('name');
        $info=$qq->select();
        $this->assign('info',$info);
        $this->display();</code>
Copy after login
Copy after login

html

<code><form action="{:U('Index/search')}" method="post">
    <input type="text" name="name" />
    <button type="submit">Submit</button>
</form></code>
Copy after login

php

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

That’s it, tp’s documentation is still very easy to understand.

<code class="php">$where['id']=123;
$info=$qq->where($where)->find();</code>
Copy after login

For details, please refer to the manual:
http://document.thinkphp.cn/manual_3_2.html

Form submission, direct GET, POST reception, or I method
See the document
http://document.thinkphp.cn/manual_3_2.html#input_var

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template