hola a todos,... soy un novato en esto,... y mi formulario de actualización de una tabla me esta dando un comportamiento ilógico o raro,... seguro que es una chorrada lo que estoy haciendo mal.... pero no lo encuentro....
mi intencion es hacer un formulario de pedido de articulos,....
la pagina me actualize la cantidad pedida y el importe del pedido,...
es decir que acte un imput.... yo calcule el importe y actualice la tabla con los dos datos,... si lo hago sin actualizar funciona,...pero al dar el comportamiento actualizar solo me actualiza el pedido y despues de dos veces el importe,... y no se por que....
mi codigo es el siguiente :
Código PHP:
<?php require_once('Connections/nacho.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_update"])) && ($HTTP_POST_VARS["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE fichas SET PEDIDO=%s, IMPORTE=%s WHERE CLIENTE=%s AND ARTICULO=%s",
GetSQLValueString($HTTP_POST_VARS['pedir'], "int"),
GetSQLValueString($HTTP_POST_VARS['valor'], "double"),
GetSQLValueString($HTTP_POST_VARS['fcliente'], "int"),
GetSQLValueString($HTTP_POST_VARS['farticulo'], "text"));
mysql_select_db($database_nacho, $nacho);
$Result1 = mysql_query($updateSQL, $nacho) or die(mysql_error());
}
mysql_select_db($database_nacho, $nacho);
$query_Recordset1 = "SELECT * FROM fichas";
$Recordset1 = mysql_query($query_Recordset1, $nacho) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><html>
<head>
<title>Documento sin título</title>
<meta http-equiv="" content="text/html; charset=iso-8859-1">
</head>
<body>
<form action="<?php echo $editFormAction; ?>" name="form1" method="POST">
<table width="75%" border="1" cellpadding="2">
<tr>
<td>cliente</td>
<td>articulo</td>
<td>descripcion</td>
<td>pedido</td>
<td>pedir</td>
<td>tarifa</td>
<td>importe</td>
</tr>
<tr>
<td><?php echo $row_Recordset1['CLIENTE']; ?></td>
<td><?php echo $row_Recordset1['ARTICULO']; ?></td>
<td><?php echo $row_Recordset1['DESCRIPCION']; ?></td>
<td><?php echo $row_Recordset1['PEDIDO']; ?></td>
<td> <input name="pedir" type="text" id="pedir" size="8">
<input name="farticulo" type="hidden" id="farticulo" value="<?php echo $row_Recordset1['ARTICULO']; ?>">
<input name="fcliente" type="hidden" id="fcliente3" value="<?php echo $row_Recordset1['CLIENTE']; ?>">
<input name="tarifa" type="hidden" value="<?php echo $row_Recordset1['TARIFA']; ?>">
<?PHP $valor2=$tarifa*$pedir ?>
<?php echo $tarifa ?>
<input name="valor" type="text" id="valor" value="<?php echo $valor2 ?>">
<input type="submit" name="Submit" value="Enviar">
</td>
<td><?php echo $row_Recordset1['TARIFA']; ?></td>
<td><?php echo $row_Recordset1['IMPORTE']; ?></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
</form>
<table width="75%" border="1" cellpadding="2">
<tr>
<td> variable valor <?php echo $valor2 ?></td>
<td> variable pedir <?php echo $pedir ?></td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
me gustaria que alguien me orientara al respecto,...
muchas gracias
y un cordial saludo
<!-- Edición: Favor de utilizar las etiquetas correspondientes para encerrar código -->