From f7aaafac2bc2a5236b1f262d60a9d2fe3ca38c82 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Wed, 16 Mar 2011 20:33:10 +0000 Subject: Only show active weights, and also properly strip low-order zeros from amounts. --- food_quantity.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/food_quantity.php b/food_quantity.php index 3d8a2a4..b938745 100644 --- a/food_quantity.php +++ b/food_quantity.php @@ -29,6 +29,7 @@ $sql = sprintf (" FROM foodDescs LEFT JOIN weights ON foodDescs.ndb_no = weights.ndb_no WHERE foodDescs.ndb_no = '%s' + AND weights.usda_status = 'active' ", $db->_dbConn->Concat("foodDescs.long_desc", "', '", "foodDescs.comname"), $food @@ -53,9 +54,8 @@ incrementPopularityCounter($food, "foodDescs"); # some data housekeeping for ( $idx = 0; $idx < count($db->_rows); $idx++ ) { # the data from the USDA frequently has low order, unnecessary zeros to the - # right of the decimal. here we strip off any superfluous zeros and/or - # decimal points - $db->_rows[$idx]['amount'] = trim($db->_rows[$idx]['amount'], ".0"); + # right of the decimal. multipying by 1 is just an easy way to remove them. + $db->_rows[$idx]['amount'] = $db->_rows[$idx]['amount'] * 1; # trim any extra commas from the end of foodDesc, as may appear # due to the concatenation of long_desc and comname with a comma -- cgit v1.2.3