search

Home  >  Q&A  >  body text

Thinkphp has some issues about passing parameters to view

Click on the a tag to transmit the parameter id to the controller. The controller queries the record value of the id row from the data table and displays it in the view through assign. However, when clicking on different links, the first row of records in the data table is displayed. Is there something wrong with the writing on the controller side?

<a href="{:U('MemberList/update?username=')}{$v.username}">编辑</a> 
public function update($username)
{
    //默认显示添加表单
    if (!IS_POST) {
        $model = M('register')->find(I('$username'));;
        $this->assign('model',$model);
        $this->display();
    }
    //…………
}
<form action="{:U('MemberList/update?username=')}{$model.username}" method="post">
    <p class="form-group">
        <label>学员名称</label>
        <input class="form-control" type="text" name="username" value="{$model.username}">
    </p>
<form>
给我你的怀抱给我你的怀抱2703 days ago891

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-07-05 09:58:02

    {:U('MemberList/update',array('username'=>$v['username']))}

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-07-05 09:58:02

    The correct answer on the first floor, read more documents to get the truth

    reply
    0
  • Cancelreply