Hi All,

I cannot seem to figure out this one.

I have the following php code in a form:

<input name="id[]" type="hidden" value="<? echo $arr_items
['fld_prod_id']; ?>" />
<input name="qty[]" type="text" class="numAlign" id="qty" value="<?
echo $arr_items['fld_qty']; ?>" size="3" maxlength="4" />

When the form is posted, it runs the update_cart function (see
below) to update the cart contents for each item. When I echo the
for loop it returns the right paramaters, but when I run the UPDATE
SQL statement it empties the table. However, when I run the the SQL
statement in the MySQL Cmd prompt it works.

I am hoping some of you experts can help.

Thanks,
Greg

function update_cart($arr){

$db = New DB;
$max = count($arr[id]);
for($i=0; $i<$max; $i++){
  $id = $arr[id][$i];
  $qty = $arr[qty][$i];
  validate_qty($qty);
  $sql = $db->query("
                 UPDATE
                  tbl_cart_items
                 SET
                  fld_qty = '$qty',
                  fld_date = now()
                 WHERE
                  fld_cart_id = '$_COOKIE[cart_id]'
                 AND
                  fld_prod_id = '$id'
                 ")
                 or $db->PrintErrors();
}
return true;
}






Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to