I am trying to run a foreach loop in the following page to get all the items name,price and quantity from the codeigniter cart library.but my foreach loop is not working in the following page?please help.
<?php
$cdata = $this->cart->contents(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Website Payment Standard</title>
<script type="text/javascript" language="javascript">
function paypal_submit()
{
var actionName='https://www.sandbox.paypal.com/cgi-bin/webscr';
document.forms.frmOrderAutoSubmit.action=actionName;
document.forms.frmOrderAutoSubmit.submit();
}
</script>
</head>
<!--onload="paypal_submit();"-->
<body onload="paypal_submit();" >
<form style=" padding:0px;margin:0px;" name="frmOrderAutoSubmit" method="post" >
<input type="hidden" name="upload" value="1">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="sumon_goran@yahoo.com">
<?php foreach ($cdata as $v_cdata) { ?>
<input type="hidden" name="quantity" value="<?php echo $v_cdata['qty']; ?> " >
<input type="hidden" name="item_name" value="<?php echo $v_cdata['name']; ?> " >
<input type="hidden" name="amount" value="<?php echo $v_cdata['price']; ?> " >
<?php } ?>
<input type="hidden" name="rm" value="2" />
<input TYPE="hidden" name="address_override" value="0">
<input type="hidden" name="address1" value="<?php echo $billing_address;?>">
<input type="hidden" name="address2" value="<?php echo $shipping_info->address; ?>">
<input type="hidden" name="city" value="<?php echo $shipping_info->city; ?>">
<input type="hidden" name="zip" value="<?php echo $shipping_info->zip_code; ?>">
<input type="hidden" name="phone" value="<?php echo $shipping_info->phone; ?>">
</form>
</body>
</html>
Try this
<?php foreach ($cdata as $key=>$v_cdata) { ?>
<input type="hidden" name="quantity" value="<?php echo $v_cdata['qty']; ?> " >
<input type="hidden" name="item_name" value="<?php echo $v_cdata['name']; ?> " >
<input type="hidden" name="amount" value="<?php echo $v_cdata['price']; ?> " >
<?php } ?>
0 comments:
Post a Comment