i have a table called info. with column, i wat to plus the data my outside column.
example below
id | fname(var) | lname(var) | outside(int)
1 ryan cruz 2
2 robert cruz 3
on my view i want the result is 5. is this possible?
⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠
Posted 17 April 2013 - 23:47 PM
i have a table called info. with column, i wat to plus the data my outside column.
example below
id | fname(var) | lname(var) | outside(int)
1 ryan cruz 2
2 robert cruz 3
on my view i want the result is 5. is this possible?
Posted 18 April 2013 - 08:23 AM
Where do you want this displayed?
If you want it just under your table you can easily make a model and your own queries e.g. [SELECT SUM(outside) FROM info]
and then just display the result.
Posted 20 April 2013 - 02:18 AM
thank you sir, ill try it later, by the way how can i dispay the result? sorry new to CI and GC.. thnx..
Posted 21 April 2013 - 00:30 AM
// example code from the documentation of CI // http://ellislab.com/codeigniter/user-guide/general/views.html // your controller <?php class Blog extends CI_Controller { function index() { $data['title'] = "My Real Title"; $data['heading'] = "My Real Heading"; $this->load->view('blogview', $data); } } ?> // your view file <html> <head> <title><?php echo $title;?></title> </head> <body> <h1><?php echo $heading;?></h1> </body> </html>
Posted 21 April 2013 - 09:05 AM
hi again, dreon. i don't really get it, but if you mean that you want to sum a data in a row, maybe this is what are you looking for :
1. use callback :
$crud->callback_column('outside',array($this,'callback_plus'));
2. this is callback_plus function :
function callback_plus($value, $row) { $plus = $row->outside_1+ $row->outside_2; return $plus." pcs"; }