[英]how to pass value from controller to view in code igniter?
Code in controller 控制器代码
public function store_service_provider() {
$get = file_get_contents('php://input');
$json_decode = json_decode($get,true);
foreach ($json_decode as $key => $value) {
$data[$key] = $value;
}
$data['role'] ='provider'; // assign role as provider
$record = $this->serviceprovider_model->store_service_provider($data);
if($record == '2'){
$data['json'] = json_encode(array('flag' => 'false', 'message'=> 'you have account with this email id Thank you '));
$this->load->view('jsonview', $data);
} else {
log_message("info",json_encode($record));
$message['uname'] = '<html><h1>Hi '.$record['first_name']. " " .$record['last_name'].'</h1><br\>
<h2><strong>Welcome to Look My Service.</strong></h2><br/>
<h3>Your Username: '.$record['email'].'</h3><br\>
<h2>To set your password
<a href ="'.base_url().'serviceprovider#/change_password/'.$record['id'].'">Click here </a></h2><br\>
<strong> Thank You </strong></html>';
$this->email->to($data['email']);
$this->email->subject('Hall-book');
$this->email->message(''.$message['uname'].'');
$this->email->message($this->>view('hall_service/email_message',$record,true));
$contact_number = $this->input->post("service_seeker_contact_number");
if(!$this->email->send()) {
$data['json'] = json_encode(array('flag' => 'email_error', 'message'=> ' not correct login '));
$this->load->view('jsonview', $data);
}else{
$message = 'Welcome to Look My Service. Your Username : '.$record['email'].' To set your password check you email Thank you.';
send($data['phone'], $message);
echo json_encode(array('flag' => 'true', 'message'=> 'correct login '));
}
}
}
enter code here 在此处输入代码
<html>
<head>
<title></title>
</head>
<body>
<h1>sudarshan</h1>
<?php foreach($record as $record):?>
<span><?php echo $record; ?></span><br>
<h1>Hi <?=$record->first_name?> " " <?=$record['last_name']?></h1><br/>
<h2><strong>Welcome to Look My Service.</strong></h2><br/>
<h3>Your Username: <?=$record->email?></h3><br/>
<h2>To set your password
<a href ="base_url()serviceprovider#/change_password/<?=$records['id']?>">Click here </a></h2><br/>
<?php endforeach;?>
<strong> Thank You </strong>
</body>
</html>
Am passing a $record to a view,in controller i can fetch all the values but in i can't fetch the values of $record,How to resolve this problem?How can i disable a link once it is clicked 我将$记录传递给一个视图,在控制器中我可以获取所有值,但在我无法获取$ record的值,如何解决此问题?如何点击链接后禁用链接
@aruna angadi @aruna angadi
Always remember when you pass any data in variable to view in controller file then you can't get same name variable name in the view file. 永远记住当您将变量中的任何数据传递给控制器文件中的视图时,您无法在视图文件中获取相同的名称变量名称。
You have to go just one step down to get the data. 您只需向下一步即可获取数据。
Example:- 例:-
if you want to pass 如果你想通过
$data = array();
$data['record'] = $my_record_data;
$this->load->view('view_file_name',$data);
then you will get data with $record variable. 那么你将获得带有$ record变量的数据。
and you can use like this 你可以像这样使用
$record
in your view file. 视图文件中的
$record
。
thanks 谢谢
In controller 在控制器中
add code 添加代码
$data = array(); $ data = array();
$data['record'] = $record; $ data ['record'] = $ record;
$this->email->message($this->>view('hall_service/email_message',$data,true)); $这 - >的电子邮件 - >消息($这 - >>视图( 'hall_service / email_message',$数据,真));
instead of 代替
$this->email->message($this->>view('hall_service/email_message',$record,true)); $这 - >的电子邮件 - >消息($这 - >>视图( 'hall_service / email_message',$记录,真));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.