How to show the data from db table in my single pages

Permalink 2 users found helpful
Hi
I am developing web application using C5
I have the problem, how to show the data from database table in single pages.

After getting the data from controller by following code
controller:
public function on_start(){
      Loader::model('clientinfo');      
      $cldt = clientinfo::get();
      $this->set('cldt',$cldt);



Single pages
<?php foreach($cldt as $data){
               echo("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td><td>$data[5]</td></tr>"); } ?>


i attached cli.png its showing empty table,
How to solve and where i did wrong?
Any one give the idea how to do this?



thanks
Kumar

1 Attachment

 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
try to set the controller things on view function
public function view(){
  //code goes here..
}


Rony
shankumars replied on at Permalink Reply
No man the same empty table only show.
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
If you print the $cldt variable into controller, is it showing the array?
shankumars replied on at Permalink Reply 1 Attachment
yeah its showing like this attachment. pfa
ronyDdeveloper replied on at Permalink Best Answer Reply
ronyDdeveloper
Ohhh.. Your array index is not like [0], [1].. It will be like [c_id], [c_name] ....

Rony
cjramki replied on at Permalink Reply
cjramki
Hi @shankumar...
I saw your attachment...
I agree with Rony... Your array index should be like [c_id], [c_name].
shankumars replied on at Permalink Reply
thanks rony and cjramki

this code properly work

echo "<tr><td>".$data[c_id]."</td><td>".$data[c_company_name]."
</td><td>".$data[c_rep_name]."</td><td>".$data[c_email]."
</td><td>".$data[c_contact_no]."</td><td>".$data[c_sec_contact_no]."
</td></tr>";


yeah i got output...


thanks
Kumar