Thinkphp Study 10

Source: Internet
Author: User

Query operations

Search under the Action module user

1  Public functionsearch () {2           //determine if the username has been passed in and is not empty3           if(isset($_post[' username ']) &&$_post[' username ']!=NULL){4               //regardless of whether {it appears before or after, only the curly braces will be considered as a delimiting symbol when they are next to each other. Do not add spaces between them, otherwise they will be treated as ordinary curly braces.5               $where[' username ']=Array(' Like ', "%{$_post[' Username ']} %"); 6           }7           if(isset($_post[' Sex ']) &&$_post[' Sex ']!=NULL){8               $where[' Sex ']=Array(' eq ',$_post[' Sex ']);9           }Ten           $m=m (' User '); One           //similar to select * from ' Tp_user ' WHERE (' username ' like '% Li ') and (' sex ' = ' 0 ') A         $data=$m->where ($where),Select (); -         if($data==NULL){ -             $this->error ("No query to results!") ", ' Index '); the         } -         Else{ -         $this->assign (' Data ',$data); -         $this->display (' Index '); +         } -}

User-corresponding index.html template

1<div style= "width:400px;margin:0 auto;" >2<form action= "__url__/search" method= "POST" >3Name: <input type= "text" name= "username"/> Sex: <input type= "Radio" name= "Sex" value= "1"/> male <input type= " Radio "name=" Sex "value=" 0 "/>female4<input type= "Submit" value= "Query"/>5 6</form>7 8<table border= ' 1 ' width= ' 400px ' align= ' center ' >9<tr>Ten<th>Id</th> One<th>User</th> A<th>sex</th> -<th> Operations </th> -</tr> the<volist name= ' data ' id= ' VO ' > -<tr> -<td><{$vo.id}></td> -<td><{$vo.username}></td> +<td><{$vo.sex}></td> -<td><a href= '/thinkphp/test/index.php/user/del/id/<{$vo .id}> ' > Delete </a>|<a href= '/ thinkphp/test/index.php/user/modify/id/<{$vo .id}> ' > Modify </a></td> +</tr> A      at</volist> -</table> -<input type= "button" value= "Add" onclick= "jump ()"/> -</div>

Thinkphp Study 10

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.