CodeIgniter Forums
how to display a mysql table class in a View - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: how to display a mysql table class in a View (/showthread.php?tid=60613)



how to display a mysql table class in a View - El Forum - 05-09-2014

[eluser]Neoraj3.0[/eluser]
Hi
I read http://ellislab.com/codeigniter/user-guide/libraries/table.html for generating tables in CI.

This works well in the controller:


$this->load->library('table');

$query = $this->db->query("SELECT * FROM my_table");

echo $this->table->generate($query);



But how do you display it in the view instead? I am sort of new to CI.


how to display a mysql table class in a View - El Forum - 05-09-2014

[eluser]Neoraj3.0[/eluser]
Ok nevermind I figured it out.

I needed to change:

echo $this->table->generate($query);

to:

$data['wer'] = $this->table->generate($query);

Then in the view add this code: <?= $wer? >