snrecords Posted November 27, 2007 Share Posted November 27, 2007 Hey all (beginner here) .... I'm trying show the cheapest price for a number of packages in a category. Some categories have 3 packages, while some have 5 and others have 1. I have all the code for the function, but believe my display code is wrong ... I'm trying to figure out why my output shows only 1 number when it's supposed to show the whole amount (in this case a dollar amount ...) Here's the function: function get_chipest_pack($package_id) { global $vars, $mdb, $category, $island; $query = "SELECT MIN( product_price ) FROM product_price LEFT JOIN product ON ( product.product_id = product_price.product_id ) LEFT JOIN product_attribute ON ( product_attribute.product_id = product_price.product_id ) LEFT JOIN product_category_xref ON ( product_category_xref.product_id = product.product_parent_id ) WHERE shopper_group_id = '5' AND `category_id` = '" . $package_id . "' AND POSITION( 'adult' IN `attribute_value_1` ) <>0"; //echo($query); //var_dump($query); $rs =& $mdb->Execute($query); $ret_value = $rs->fields[0]; return $ret_value; } Now here's the code that displays only one number... Oh by the way ... it shows the correct first number, but doesn't show the whole price. <?phpif (isset($_GET['category_id'])) $category_id = $_GET['category_id']; else header("Location: index.php"); $ci = get_package_info($category_id); $cd = get_chipest_pack($category_id); ?> <?=$cd["category_id"]?> Also please keep in mind that whatever variable I input into <?=$cd["category_id"]?> ... (e.g. <?=$cd["sdfsdfs"]?> ), it still shows the correct first number. Any help is appreciated... Link to comment https://forums.phpfreaks.com/topic/79033-shows-only-1-number/ Share on other sites More sharing options...
cooldude832 Posted November 27, 2007 Share Posted November 27, 2007 you are returning a variable thus it needs to be echoed so you should say <?php if (isset($_GET['category_id'])) $category_id = $_GET['category_id']; else header("Location: index.php"); $ci = get_package_info($category_id); $cd = get_chipest_pack($category_id); ?> <?php print_r($cd); ?> that will explain it a bit more Link to comment https://forums.phpfreaks.com/topic/79033-shows-only-1-number/#findComment-399962 Share on other sites More sharing options...
snrecords Posted November 27, 2007 Author Share Posted November 27, 2007 Thank you!!! Link to comment https://forums.phpfreaks.com/topic/79033-shows-only-1-number/#findComment-400044 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.