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?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-06 13:53:33985browse

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>

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>

html

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

php

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

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

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

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

Statement:
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