Jump to content

Array paases as hidden variable problem


php1

Recommended Posts

I have a form which pass array as hidden variable to a php script. The value assigned to array is a variable which is from a for loop.

my problem is that when i try to take the value frm the second page i got only the value as "atrray". can any body please hepl?? urgent?? i will paste my code here.

 

1st page(there are codes before this and after this)

---------------------------------------------------------------------------------------------------------------------------------------------------------

<?php
$cartContent = getCartContent();

$numItem = count($cartContent);

$subTotal = 0;

for ($i = 0; $i < $numItem; $i++) {

extract($cartContent[$i]);        //from cartcontent we get pd_* and cat_* values * represents id,price,qty etc

$productUrl = "index.php?c=$cat_id&p=$pd_id";

$subTotal += $pd_price * $ct_qty;

?>

<tr class="content"> 

  <td width="80" align="center"><a href="<?php echo $productUrl; ?>"><img src="<?php echo $pd_thumbnail; ?>" border="0"></a></td>

  <td><a href="<?php echo $productUrl; ?>"><?php echo $pd_name; ?></a></td>

   <td align="right"><?php echo displayAmount($pd_price); ?></td>

  <td width="75"><input name="txtQty[]" type="text" id="txtQty[]" size="5" value="<?php echo $ct_qty; ?>" class="box" onKeyUp="checkNumber(this);">

  <input name="hidCartId[]" type="hidden" value="<?php echo $ct_id; ?>">

  <input name="hidProductId[]" type="hidden" value="<?php echo $pd_id; ?>">
  

  </td>

  <td align="right"><?php echo displayAmount($pd_price * $ct_qty); ?></td>

  <td width="75" align="center"> <input name="btnDelete" type="button" id="btnDelete" value="Delete" onClick="window.location.href='<?php echo $_SERVER['PHP_SELF'] . "?action=delete&cid=$ct_id"; ?>';" class="box"> 

  </td>

</tr>

<?php 

}

?>

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

2nd page

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<?php
function updateCart()

{
   $cartId     = $_POST['hidCartId'];
$productId  = $_POST['hidProductId'];

$itemQty    = $_POST['txtQty'];

$numItem    = count($itemQty);

$numDeleted = 0;

$notice     = '';
print_r($itemQty);  //ouput is array
}?>

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 

urgent any body plaese help. thanks in advance

 

(edited by kenrbnsn to add


tags)

Link to comment
https://forums.phpfreaks.com/topic/110026-array-paases-as-hidden-variable-problem/
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.