I am working on CodeIgniter, but unable to output entity that has timestamp at mysql end but other entities are working(coming out well) -


/// controller has :

       $users = $this->loginmodel->getalluser();                $data["users"] = $users;                $this->load->view("login/allusers",$data); 

/// view has :

    foreach($users $user){             echo "username : ".$user->getusername()." time :   ".$user->gettimepost()."<br>";             }  

question : $user->gettimepost() generating error during echo

here small code can use you.

controller

function viewallusers() {     $data['users'] = $this->loginmodel->getallusers();     $this->load->view('login/allusers',$data); } 

model

function getallusers() { $this->db->select('*'); $this->db->from('tblname'); $query = $this->db->get(); return $query->result(); } 

view

foreach($users $u) {   echo "username : ".$u->user_name;   echo " time :   ".$user->time_stamp;   echo "<br>"; } 

where user_name , time_stamp table columns. using model have given, gives object type of got database. , can accessible using foreach using arrow.

the syntax follows:

$u->your_table_column_name_you_want_to_get 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -