Dreamweaver - Actualizar Múltiples Registros a la vez

 
Vista:
sin imagen de perfil

Actualizar Múltiples Registros a la vez

Publicado por Jorge (2 intervenciones) el 16/01/2013 17:12:15
Quisiera que me ayudaran con la actualización de registros pero en forma múltiple, es decir que se pueda modificar todos los datos mostrados. En mi caso tengo las notas de los alumnos, y lo quiero es que un docente, pueda modificar todas las notas de una clase sin necesidad de ir seleccionando una a una. El código que he generado con Dreamweaver para actualizar UN SÓLO REGISTRO Y QUE SI FUNCIONA es el siguiente:

******************************************************
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  $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;
}
}
 
$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 notas SET lt1=%s, lt2=%s, lt3=%s, pf=%s WHERE nombre_alumno=%s AND curso=%s",
                       GetSQLValueString($_POST['lt1'], "text"),
                       GetSQLValueString($_POST['lt2'], "text"),
                       GetSQLValueString($_POST['lt3'], "text"),
                       GetSQLValueString($_POST['pf'], "text"),
                       GetSQLValueString($_POST['nombre_alumno'], "text"),
                       GetSQLValueString($_POST['curso'], "text"));
 
  mysql_select_db($database_cNotas, $cNotas);
  $Result1 = mysql_query($updateSQL, $cNotas) or die(mysql_error());
 
  $updateGoTo = "doc_notas_mod2.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
$colname_not = "-1";
if (isset($_GET['nombre_alumno'])) {
  $colname_not = $_GET['nombre_alumno'];
}
$colcurso_not = "-1";
if (isset($_GET['curso'])) {
  $colcurso_not = $_GET['curso'];
}
mysql_select_db($database_cNotas, $cNotas);
$query_not = sprintf("SELECT * FROM notas WHERE nombre_alumno = %s AND curso = %s", GetSQLValueString($colname_not, "text"),GetSQLValueString($colcurso_not, "text"));
$not = mysql_query($query_not, $cNotas) or die(mysql_error());
$row_not = mysql_fetch_assoc($not);
$totalRows_not = mysql_num_rows($not);
 
$colname_usu = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_usu = $_SESSION['MM_Username'];
}
mysql_select_db($database_cNotas, $cNotas);
$query_usu = sprintf("SELECT * FROM docentes WHERE usuario = %s", GetSQLValueString($colname_usu, "text"));
$usu = mysql_query($query_usu, $cNotas) or die(mysql_error());
$row_usu = mysql_fetch_assoc($usu);
$totalRows_usu = mysql_num_rows($usu);
 
mysql_select_db($database_cNotas, $cNotas);
$query_gru = "SELECT * FROM grupos WHERE nombre_docente = '$row_usu[nombre_docente]'";
$gru = mysql_query($query_gru, $cNotas) or die(mysql_error());
$row_gru = mysql_fetch_assoc($gru);
$totalRows_gru = mysql_num_rows($gru);
?>

*****************************************************************

Por favor necesito su ayuda ...
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de xve
Val: 96
Oro
Ha mantenido su posición en Dreamweaver (en relación al último mes)
Gráfica de Dreamweaver

Actualizar Múltiples Registros a la vez

Publicado por xve (369 intervenciones) el 16/01/2013 20:35:45
Hola Jorge, aquí no veo ningún input para poder modificar el registro que comentas... puede ser que falte una parte del código?
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil

Actualizar Múltiples Registros a la vez

Publicado por Jorge (2 intervenciones) el 16/01/2013 22:54:51
Muchas gracias por contestar esta la parte del formulario que no había copiado, porque en realidad es bastante código:

*********************************************************************************************************
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
        <table align="center">
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Nombre del Alumno :</td>
            <td><?php echo $row_not['nombre_alumno']; ?></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Unidad Did&aacute;ctica :</td>
            <td><input type="text" name="curso" value="<?php echo htmlentities($row_not['curso'], ENT_COMPAT, 'iso-8859-1'); ?>" size="50" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Literal 1 :</td>
            <td><input type="text" name="lt1" value="<?php echo htmlentities($row_not['lt1'], ENT_COMPAT, 'iso-8859-1'); ?>" size="8" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Literal 2 :</td>
            <td><input type="text" name="lt2" value="<?php echo htmlentities($row_not['lt2'], ENT_COMPAT, 'iso-8859-1'); ?>" size="8" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Literal 3 :</td>
            <td><input type="text" name="lt3" value="<?php echo htmlentities($row_not['lt3'], ENT_COMPAT, 'iso-8859-1'); ?>" size="8" /></td>
          </tr>
          <tr valign="baseline">
            <td nowrap="nowrap" align="right">Promedio Final :</td>
            <td><input type="text" name="pf" value="<?php echo htmlentities($row_not['pf'], ENT_COMPAT, 'iso-8859-1'); ?>" size="8" /></td>
          </tr>
          <tr valign="baseline">
            <td colspan="2" align="center" nowrap="nowrap"><input type="submit" value="Actualizar registro" /></td>
          </tr>
        </table>
        <input type="hidden" name="MM_update" value="form1" />
        <input type="hidden" name="nombre_alumno" value="<?php echo $row_not['nombre_alumno']; ?>" />
      </form>
 
 
</body>
</html>
<?php
mysql_free_result($not);
?>

**********************************************************
Muchas gracias por tu ayuda. Recuerda que estoy trabajando con Dreamweaver CS3
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar