Jump to content

Shows Only 1 number!!


snrecords

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.