php - Output Growth between Numeric Datafields in database -
php - Output Growth between Numeric Datafields in database -
i output growth percentage between age 20 , age 19. should able "height growth = 3" (by taking height 178 - 175) or there "height growth = .017%" (178/175).
my code looks this
<table> <thead><tr><td>age</td><td>height</td><td>height growth %</td><td>weight</td></tr> </thead> <tbody> <?php foreach ($healthdata->result_array() $row) { echo "<tr><td>".$row['age']."</td><td>".$row['height']."</td><td>%</td> <td>".$row['weight']."</td></tr>"; } ?> </tbody></table> my model looks this
function display_healthdata() { $healthdata = $this->db->query("select * healthdata id = '1' order age desc;"); homecoming $healthdata; } essentially don't know kind of sql statement can or code need write able create these calculations. thought may not possible calculation on database or in php , may need on client side instead of server side.
please allow me know other info can/should add together more helpful.
problem solved people finding code helped... code used issue following:
select t1.*, (t1.height - ifnull(t2.height, 0)) growth healthdata t1 left bring together healthdata t2 on (t2.age = (t1.age - 1)) t1.id = '1' grouping age
you can sql joins... i'm tired give proper answer, here's link problem seems similar yours. =d
how difference between 2 rows column field?
edit
i'll take crack @ it. not guaranteed not blow house; stated i'm tired ;)
select t1.*, (t1.height - ifnull(t2.height, 0)) growth healthdata t1 left bring together healthdata t2 on (t2.age = (t1.age - 1)) php sql
Comments
Post a Comment