Problema actualización de datos con php
Hola experto tengo el siguiente problema, necesito actualizar una tabla a través de un formulario PHP, los datos son todos distintos, la tabla tiene Id que en este caso es conArea adjunto código, de antemano gracias
<?php require_once('../../Connections/nacman.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? Stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? Mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}
$colname_informe = "-1";
if (isset($_GET['IdArea'])) {
$colname_informe = $_GET['IdArea'];
}
mysql_select_db($database_nacman, $nacman);
$query_informe = sprintf("SELECT * FROM dat_informe WHERE IdArea = %s ORDER BY Nombre ASC", GetSQLValueString($colname_informe, "int"));
$informe = mysql_query($query_informe, $nacman) or die(mysql_error());
$row_informe = mysql_fetch_assoc($informe);
$totalRows_informe = mysql_num_rows($informe);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . Htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
foreach($_POST['conArea'] as $key =>$value) {
$updateSQL = sprintf("UPDATE dat_informe SET Nombre=%s, P1=%s, Fallas_1=%s WHERE conAreas = $value",
GetSQLValueString($_POST['Nombre'][$key], "text"),
GetSQLValueString($_POST['P1'][$key], "double"),
GetSQLValueString($_POST['Fallas_1'][$key], "int"));
mysql_select_db($database_nacman, $nacman);
$Result1 = mysql_query($updateSQL, $nacman) or die(mysql_error());
}
$updateGoTo = "carga.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$colname_informe = "-1";
if (isset($_GET['IdArea'])) {
$colname_informe = $_GET['IdArea'];
}
mysql_select_db($database_nacman, $nacman);
$query_informe = sprintf("SELECT * FROM dat_informe WHERE IdArea = %s ORDER BY Nombre ASC", GetSQLValueString($colname_informe, "int"));
$informe = mysql_query($query_informe, $nacman) or die(mysql_error());
$row_informe = mysql_fetch_assoc($informe);
?>
<!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=utf-8" />
<title>Documento sin título</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table border="1" align="center">
<tr align="center">
<td nowrap="nowrap" align="center">Nombre:</td>
<td nowrap="nowrap" align="center">P1:</td>
<td nowrap="nowrap" align="center">Fallas_1:</td>
</tr>
<?php do { ?>
<tr>
<td><label>
<input type="text" name="Nombre[]" id="Nombre[]" value="<?php echo $row_informe['Nombre']; ?>" size="60" />
</label></td>
<td><label>
<input type="text" name="P1[]" id="P1[]" value="<?php echo $row_informe['P1']; ?>" size="10" />
</label></td>
<td><label>
<input type="text" name="Fallas_1[]" id="Fallas_1[]" value="<?php echo $row_informe['Fallas_1']; ?>" size="10" />
</label></td>
</tr>
<?php } while ($row_informe = mysql_fetch_assoc($informe)); ?>
<tr>
<td colspan="3" align="center">
<input type="submit" value="Guardar" /></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1" />
<input type="hidden" name="conArea" value="<?php echo $row_informe['conArea']; ?>" />
</form>
<p> </p>
</body>
</html>
<?php
mysql_free_result($informe);
?>