select - codeigniter, get the maximum value in mysql table column -


i'm using codeigniter 2.
i've mysql table column storing time taken each student.
eg. 1.2327, 0.6547, 1.9876

i want max. value column.

this code:

$this->db->select_max('time_taken', 'time'); $result = $this->db->get('students');   echo $result->row()->time; 

when echo result, give me value of 2(correct value should 1.9876).
correct way value need, thanks?

try:

$this->db->select_max('time_taken time'); $result = $this->db->get('students')->row();   echo $result->time; 

edit: make sure database table field (i.e time_taken) decimal, not integer.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -