Jump to content

output of the array variable


phpworker

Recommended Posts

Hi

In the following code,at the 21st  line, the code to print the  value of the variable $cartContent  is:

print_r ($cartContent);

function getCartContent()
{
$cartContent = array();

$sid = session_id();
$sql = "SELECT ct_id, ct.pd_id, ct_qty, pd_name, pd_price, pd_thumbnail, pd.cat_id
		FROM tbl_cart ct, tbl_product pd, tbl_category cat
		WHERE ct_session_id = '$sid' AND ct.pd_id = pd.pd_id AND cat.cat_id = pd.cat_id";

$result = dbQuery($sql);

while ($row = dbFetchAssoc($result)) {
	if ($row['pd_thumbnail']) {
		$row['pd_thumbnail'] = WEB_ROOT . 'images/product/' . $row['pd_thumbnail'];
	} else {
		$row['pd_thumbnail'] = WEB_ROOT . 'images/no-image-small.png';
	}
	$cartContent[] = $row;
}
         
        print_r ($cartContent);	
return $cartContent;
}

 

I get the output at runtime as,

Array ( [0] => Array ( [ct_id] => 120 [pd_id] => 22 [ct_qty] => 4 [pd_name] => volvo1 [pd_price] => 100.00 [pd_thumbnail] => /plaincart/images/no-image-small.png [cat_id] => 14 ) )

 

When i want to see only the ct_id key and its value which is 120,ignoring all other keys and values.

what is the code for it..

 

thanks

phpworker

Link to comment
https://forums.phpfreaks.com/topic/207263-output-of-the-array-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.