Saludos amigos.... aqui nuevamente con otra consulta.... tengo un formulario de actualizacion de datos que es generado mediante un loop el problema que tengo es que quiero actualizar varios registros a la ves desde el mismo formulario el formulario es el siguiente:
<?php require_once('Connections/fish.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 = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
/* $updateSQL = sprintf("UPDATE preguntas SET grupo=%s, codigo_p=%s, pregunta=%s, img=%s, fecha=Now(), aciertos=%s, estatus='A' WHERE num=%s",
GetSQLValueString($_POST['grupo'], "text"),
GetSQLValueString($_POST['codigo_p'], "text"),
GetSQLValueString($_POST['pregunta'], "text"),
GetSQLValueString($_POST['img'], "text"),
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['aciertos'], "text"),
GetSQLValueString($_POST['estatus'], "text"),
GetSQLValueString($_POST['num'], "int"));
mysql_select_db($database_fish, $fish);
$Result1 = mysql_query($updateSQL, $fish) or die(mysql_error());*/
$updateGoTo = "inicio.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
$maxRows_actualizar = 10;
$pageNum_actualizar = 0;
if (isset($_GET['pageNum_actualizar'])) {
$pageNum_actualizar = $_GET['pageNum_actualizar'];
}
$startRow_actualizar = $pageNum_actualizar * $maxRows_actualizar;
mysql_select_db($database_fish, $fish);
$query_actualizar = "SELECT * FROM preguntas ORDER BY num ASC";
$query_limit_actualizar = sprintf("%s LIMIT %d, %d", $query_actualizar, $startRow_actualizar, $maxRows_actualizar);
$actualizar = mysql_query($query_limit_actualizar, $fish) or die(mysql_error());
$row_actualizar = mysql_fetch_assoc($actualizar);
if (isset($_GET['totalRows_actualizar'])) {
$totalRows_actualizar = $_GET['totalRows_actualizar'];
} else {
$all_actualizar = mysql_query($query_actualizar);
$totalRows_actualizar = mysql_num_rows($all_actualizar);
}
$totalPages_actualizar = ceil($totalRows_actualizar/$maxRows_actualizar)-1;
?><!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=iso-8859-1" />
<title>Actualizacion Preguntas Fish</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<table width="80%" border="1">
<tr>
<td>Numero Pregunta </td>
<td>Pregunta</td>
<td>Imagen</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_actualizar['num']; ?>
<input name="num" type="hidden" id="num" value="<?php echo $row_actualizar['num']; ?>" />
<input name="grupo" type="hidden" id="grupo" value="<?php echo $row_actualizar['grupo']; ?>" />
<input name="codigo_p" type="hidden" id="codigo_p" value="<?php echo $row_actualizar['codigo_p']; ?>" />
<input name="fecha" type="hidden" id="fecha" value="<?php echo $row_actualizar['fecha']; ?>" />
<input name="aciertos" type="hidden" id="aciertos" value="<?php echo $row_actualizar['aciertos']; ?>" />
<input name="estatus" type="hidden" id="estatus" value="<?php echo $row_actualizar['estatus']; ?>" /></td>
<td><input name="pregunta" type="text" id="<?php echo $row_actualizar['num']; ?>" value="<?php echo $row_actualizar['pregunta']; ?>" /></td>
<td><input name="img" type="text" id="img" value="<?php echo $row_actualizar['img']; ?>" />
<?php
$updateSQL = sprintf("UPDATE preguntas SET grupo='".$row_actualizar['grupo']."', codigo_p='".$row_actualizar['codigo_p']."', pregunta=%s, img='".$row_actualizar['img']."', fecha=Now(), aciertos='".$row_actualizar['aciertos']."', estatus='A' WHERE num='".$row_actualizar['num']."'",
GetSQLValueString($_POST['grupo'], "text"),
GetSQLValueString($_POST['codigo_p'], "text"),
GetSQLValueString($_POST['pregunta'], "text"),
GetSQLValueString($_POST['img'], "text"),
GetSQLValueString($_POST['fecha'], "date"),
GetSQLValueString($_POST['aciertos'], "text"),
GetSQLValueString($_POST['estatus'], "text"),
GetSQLValueString($_POST['num'], "int"));
mysql_select_db($database_fish, $fish);
$Result1 = mysql_query($updateSQL, $fish) or die(mysql_error());
echo $updateSQL;
?>
</td>
</tr>
<?php } while ($row_actualizar = mysql_fetch_assoc($actualizar)); ?>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="Actualizar" /></td>
<td> </td>
</tr>
</table>
<input type="hidden" name="MM_update" value="form1">
</form>
</body>
</html>
<?php
mysql_free_result($actualizar);
?>
la verdad creo saber que el problema es que la en el UPDATE no le estoy enviando correctamente el nombre del campo pregunta, quisiera que alguien me ayudara a solventar este problema....
como siempre agradesco de antemano la ayuda...
gracias