How to get values from single coloumn |
Hello,
I have a table for personal data, which contains contents such as name, address, gender, etc. now I want to calculate the total male or female from the gender column, so I make a sql query like this: Code: SELECT gender, COUNT(*) AS total the result is : Quote:man : 3 So, how do I write the code on the model and controller and display it on my website? this is my code so far: PHP Code: public function total_gender() Thank you and sorry for my bad english
@ravhirzldi
Maybe these links will help: https://codeigniter.com/user_guide/general/views.html (simply replace the array with the results from a model method) https://www.guru99.com/codeigniter-mvc-framework.html
Controller
PHP Code: public function yourfunName(){ PHP Code: <?php echo $gener_num; ?> regards
$query->result() returns an array of objects.
Controller: PHP Code: $data['stats'] = $this->model-name->total_gender(); View: PHP Code: <table> Note: <?= is short for: <?php echo |
Welcome Guest, Not a member yet? Register Sign In |