purtroppo no, il file2.php viene usato anche per altre funzioni.
![]()
in pratica l'action del form richiama la funzione updateCart() in cui io ho inserito un'altra funzione ( si può vero annidare funzioni... :master: )
ti posto l'intero codice per quella funzione ( parliamo sempre del file2.php):
purtroppo, devo tenere la funzione query() all'interno, a meno che non esista un modo di "eludere" il form action di file1.phpCodice PHP:function updateCart()
{
$id_area = $_POST['id_area'];
$id_pag = $_POST['id_pag'];
$cartId = $_POST['hidCartId'];
$productId = $_POST['hidProductId'];
$itemQty = $_POST['txtQty'];
$numItem = count($itemQty);
$numDeleted = 0;
$notice = '';
for ($i = 0; $i < $numItem; $i++) {
$newQty = (int)$itemQty[$i];
if ($newQty < 1) {
// remove this item from shopping cart
deleteFromCart($cartId[$i]);
$numDeleted += 1;
} else {
// update product quantity
$sql = "UPDATE tbl_cart
SET ct_qty = $newQty
WHERE ct_id = {$cartId[$i]}";
dbQuery($sql);
}
//FUNZIONE QUERY CHE MI INTERESSA E DA ERRORE
function query($id_area, $id_pag)
{
if (isset($id_area) && isset($id_pag))
{
$query = mysql_query("SELECT prezzo FROM tbl_shipping WHERE id_area = ".$id_area." AND id_pag = ".$id_pag." AND id_abb ='0'")or die(mysql_error());
$row = dbFetchAssoc($query);
extract($row);
return $prezzo;
}
return "no";
}
}
if ($numDeleted == $numItem) {
// if all item deleted return to the last page that
// the customer visited before going to shopping cart
//header("Location: $returnUrl" . $_SESSION['shop_return_url']);
header('Location: home.php?page=cart');
} else {
header('Location: home.php?page=cart');
}
exit;
}

Rispondi quotando