function last_weight_increase_h($userID, $exerciseID) { $CI =& get_instance(); //get the last weight increase $CI->db->select('*'); $CI->db->select_max('weight'); $CI->db->from('sets'); $CI->db->where('exercises_id ', $exerciseID); $CI->db->where('new_maximum ', 1); $CI->db->where('users_id ', $userID); //don't want the date to be the current one // $CI->db->where('date <', 'NOW()'); $set1 = $CI->db->get()->row(); $weight1 = $set1->weight; //if no weight 1 return false if (!$weight1) { echo "Not enough data."; return false; } //get the last increase before the current one. $CI->db->select('*'); $CI->db->select_max('weight'); $CI->db->from('sets'); $CI->db->where('exercises_id ', $exerciseID); $CI->db->where('new_maximum ', 1); $CI->db->where('users_id ', $userID); $CI->db->where('weight < ', $weight1); $set2 = $CI->db->get()->row(); $weight2 = $set2->weight; //if no weight 2 return false. if (!$weight2) { echo "Not enough data."; return false; } //get the difference in weight $weightDifference = $weight1 - $weight2; $date = $set1->date; $date = format_date_h($date); echo $weightDifference . "lbs - " . $date; }
<!-- <?php foreach ($dailyListItems as $item) { ?> <div class="list-group-item" data-timeframe="1"> <span class="<?php checked_off($item->list_completed); ?> message-item"> <?php echo $item->list_contents; ?> </span> <br> <br> <em><small class="dates"><?php echo format_date_h($item->list_date); ?> </small></em> <div class="menu-li-button"> <span class="glyphicon glyphicon-menu-hamburger"></span> </div> <div class="delete menu-button-item" title="Delete Item"> <span class="glyphicon glyphicon-remove delete-button control-buttons" aria-hidden="true"></span> </div> <div class="menu-button-item" title="Check Off Item"> <span class="glyphicon glyphicon-ok control-buttons" aria-hidden="true"></span> </div> <div class="move-list-item menu-button-item" title="Move Item Up"> <span class="glyphicon glyphicon-arrow-up control-buttons" aria-hidden="true"></span> </div> <div class="move-list-item menu-button-item" title="Move Item Down">