summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Kinkade <nath@nkinka.de>2011-03-16 20:33:10 +0000
committerNathan Kinkade <nath@nkinka.de>2011-03-16 20:33:10 +0000
commitf7aaafac2bc2a5236b1f262d60a9d2fe3ca38c82 (patch)
tree4f67e8c684b7a1ba217788e0480a5ddb9ee3b7c0
parent9c7b4c554b31c932abcf05dbde5765fcfa8deddd (diff)
Only show active weights, and also properly strip low-order zeros from amounts.
-rw-r--r--food_quantity.php6
1 files 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