Welcome Guest, Not a member yet? Register   Sign In
How to perform this in CodeIgniter MVC
#2

(This post was last modified: 05-07-2016, 08:25 PM by marksman.)

Hey guys, I just got it, I don't know if this is the proper way. Please correct me if I did it wrong or please suggest a better way.

Controller:
PHP Code:
$query $this->db->query("SELECT * FROM `users`");
foreach(
$query->result_array() AS $row) {
$FirstName $row['FirstName'];
$FirstName str_replace("aaa","***",$FirstName);
$users[] = array("FirstName"=>$FirstName);
}
$data = array("users"=>$users);
$this->load->view('myview',$data); 

View:
PHP Code:
<html>
<
body>
 <?php
  
foreach($users AS $users) {
   echo $users['FirstName']."<br>";
  }
 ?>
</body>
</html> 

This will replace all "aaa" to "***" to the entire rows of column FirstName.
Did I perform it right? or there's a better way to do this?
God Bless CI Contributors Smile
Reply


Messages In This Thread
RE: How to perform this in CodeIgniter MVC - by marksman - 05-07-2016, 06:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB