PHP - Suma Filas y Columnas Mysql + PHP

 
Vista:
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 08/11/2015 20:45:22
Hola amigos, vengo con la siguiente consulta:

Tengo una Tabla en la cual quisiera sumar todos los campos de las filas:


Tabla-BD


Luego de hacer todas las sumas, quisiera representarlas de la siguiente manera en mi proyecto web (PHP):

Presentar-Tabla-en-PHP


Agradezco de antemano en lo que me puedan apoyar


Nota: La tabla tiene por nombre: cantidad de cursos nacional


Nombre-Tabla
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 Lawliet
Val: 478
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Suma Filas y Columnas Mysql + PHP

Publicado por Lawliet (351 intervenciones) el 08/11/2015 22:36:36
Hola...

Por lo menos ya tienes la consulta que te retorna los resultados necesarios o el tema es mas que nada para poder obtener esa consulta?
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 08/11/2015 23:11:52
Hola, la verdad necesito:

1. La consulta para llamar a la BD
2. El código para hacer la suma de las filas
3. El código para mostrar estos resultados como aparece en la imagen siguiente:

Presentar-Tabla-en-PHP


La imagen que te envío es como lo tengo en excel,

Agradecido de antemano,
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
Imágen de perfil de Lawliet
Val: 478
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Suma Filas y Columnas Mysql + PHP

Publicado por Lawliet (351 intervenciones) el 08/11/2015 23:16:15
Toda la información de la tabla, la sacas de una sola tabla o viene de varias tablas?
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 08/11/2015 23:40:56
De una sola hermanazo, la cual se llama: cantidad de cursos nacional

Tabla-BD
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
Imágen de perfil de Lawliet
Val: 478
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Suma Filas y Columnas Mysql + PHP

Publicado por Lawliet (351 intervenciones) el 08/11/2015 23:45:48
Serías tan amable de exportar la tabla y pasarla aquí en el tema, de esa manera puedo probar la consulta antes de mandártela ^^. En la parte superior del phpMyAdmin, existe una opción que dice exportar, solo sería cuestión de seleccionar tu tabla y la proporcionas acá ^^. Gracias!
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
Imágen de perfil de Lawliet
Val: 478
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Suma Filas y Columnas Mysql + PHP

Publicado por Lawliet (351 intervenciones) el 09/11/2015 00:20:09
Hola...

Tengo la consulta para que puedas probar, sin embargo, observe que cuando se trata de la Región Occidente y Oriente para el año 2015, no me arroja resultado; es decir, no me trae el número 9 que tienes en tu imagen, serías tan amable de validar por favor.

1
SELECT Region, Year, (Enero + Febrero + Marzo + Abril + Mayo + Junio + Julio + Agosto + Septiembre + Octubre + Noviembre + Diciembre) AS Suma FROM `cantidad de cursos nacional` GROUP BY Year, Region

Ahora bien, haciendo algunos cambios a la consulta, cuando se trata de Oriente no me muestra los resultados correspondientes a los años 2014 y 2015; es decir, no me trae el 10 ni el 9, podrías validar por favor.

1
SELECT Region, Year, (Enero + Febrero + Marzo + Abril + Mayo + Junio + Julio + Agosto + Septiembre + Octubre + Noviembre + Diciembre) AS Suma FROM `cantidad de cursos nacional` GROUP BY ID_Curso, Year, Region

Sin mas que comentar cualquier duda y/o inconveniente, aquí estamos.

Suerte!
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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 09/11/2015 00:19:09
Hola! he echo un ejemplo rápido sin probarlo, lo único es que no ordena los resultados en una tabla.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?
 
$conexion = mysqli_connect("localhost", "user", "password", "bd");
if (mysqli_connect_errno()) { echo "Error al conectar con servidor MySQL: " . mysqli_connect_error(); exit(); }
 
 
$a = "SELECT * FROM tabla";
$b = mysqli_query($conexion,$a) or die(mysqli_error());
 
while($fetch = mysqli_fetch_assoc($b)){
 
$total = $fetch["Enero"] + $fetch["Febrero"] + $fetch["Marzo"] + $fetch["Abril"] + $fetch["Mayo"] + $fetch["Junio"] + $fetch["Julio"] + $fetch["Agosto"] + $fetch["Septiembre"] + $fetch["Octubre"] + $fetch["Noviembre"] + $fetch["Diciembre"];
 
echo $total ."cursos realizados en ".$fetch["Region"]." en el año ".$fetch["Year"]." ";
 
}
 
 
?>
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 09/11/2015 01:52:45
Hermanazo lo colocque como me sugieres, pero me esta indicando lo siguiente:

Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\AppServ\www\gestion_capacitacion\02_usuario\cantcandes.php on line 369

Te paso la imagen de colo lo tengo:

Error-Codigo-01

A que se deberá?
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
Imágen de perfil de Lawliet
Val: 478
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Suma Filas y Columnas Mysql + PHP

Publicado por Lawliet (351 intervenciones) el 09/11/2015 02:11:07
Hola...

mysqli_error recibe un parámetro de entrada, correspondiente a la conexión, por lo tanto quedaría de la siguiente manera...

1
$b = mysqli_query($conexion,$a) or die (mysqli_error($conexion))

Sin mas que comentar cualquier duda y/o inconveniente, aquí estamos.

Suerte!
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 09/11/2015 02:22:17
Ups,

Ahora me indica esto: No database selected


Error-Codigo-02
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
Imágen de perfil de Lawliet
Val: 478
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Suma Filas y Columnas Mysql + PHP

Publicado por Lawliet (351 intervenciones) el 09/11/2015 02:33:12
Hola...

El error es claro, y si veo tu código efectivamente te falta seleccionar la base de datos. La función mysqli_connect recibe cuatro parámetros.

1
mysqli_connect("server","user","password","database")

El primero corresponde a la dirección de tu server, regularmente IP.
El segundo corresponde al usuario.
El tercero corresponde a la contraseña.
El cuarto corresponde al nombre de tu base de datos.

Sin mas que comentar cualquier duda y/o inconveniente, aquí estamos.

Suerte!
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 09/11/2015 03:02:44
Tienes toda la razón, mil disculpas por ese detalle,

Vamos muy bien,

Ya me indica los resultados, ahora lo que no logro es poder colocarle la tabla (por temas de diseño), ya que el "echo" esta dentro del while y no me deja colocar la tabla en el bucle.


Resultado-Sin-Tabla
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 09/11/2015 13:23:48
Para el diseño de la tabla solo se me ocurre hacerlo así:

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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?
$conexion = mysqli_connect("localhost", "root", "1234", "database");
if (mysqli_connect_errno()) { echo "Error al conectar con servidor MySQL: " . mysqli_connect_error(); exit(); }
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
table {
    border-collapse: collapse;
    border-spacing: 0;
	margin:0px;padding:0px;
}
td { width:90px; font-size:12px; text-align:center; }
</style>
</head>
<body>
<?
 
echo "<table border='1'><tr><td>&nbsp;</td><td>Andes</td><td>Centro</td><td>Centro Llanos</td><td>Centro Occidente</td><td>Gran Caracas</td><td>Guayana</td><td>Occidente</td><td>Oriente</td></tr>";
 
$a = "SELECT * FROM `cantidad de cursos nacional` WHERE Year='2012' ORDER BY Region";
$b = mysqli_query($conexion,$a) or die(mysqli_error($conexion));
 
$y = 0;
while($fetch = mysqli_fetch_assoc($b)){
if ($y < 1) { echo "<tr><td bgcolor='#000066'><span style='color:#fff; font-weight:bold;'>Cursos NI 2012</span>"; }
$y = 1;
$total = $fetch["Enero"] + $fetch["Febrero"] + $fetch["Marzo"] + $fetch["Abril"] + $fetch["Mayo"] + $fetch["Junio"] + $fetch["Julio"] + $fetch["Agosto"] + $fetch["Septiembre"] + $fetch["Octubre"] + $fetch["Noviembre"] + $fetch["Diciembre"];
 
if ($fetch["Region"] === "Andes") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Llanos") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Occidente") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Gran Caracas") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Guayana") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Occidente") { echo "<td>$total</td>"; }
else { if ($fetch["Region"] == "Oriente") { echo "<td>$total</td>"; } }
}
 
echo "</tr>";
$a = "SELECT * FROM `cantidad de cursos nacional` WHERE Year='2013' ORDER BY Region";
$b = mysqli_query($conexion,$a) or die(mysqli_error($conexion));
 
$y = 0;
while($fetch = mysqli_fetch_assoc($b)){
if ($y < 1) { echo "<tr><td bgcolor='#000066'><span style='color:#fff; font-weight:bold;'>Cursos NI 2013</span>"; }
$y = 1;
$total = $fetch["Enero"] + $fetch["Febrero"] + $fetch["Marzo"] + $fetch["Abril"] + $fetch["Mayo"] + $fetch["Junio"] + $fetch["Julio"] + $fetch["Agosto"] + $fetch["Septiembre"] + $fetch["Octubre"] + $fetch["Noviembre"] + $fetch["Diciembre"];
 
if ($fetch["Region"] === "Andes") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Llanos") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Occidente") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Gran Caracas") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Guayana") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Occidente") { echo "<td>$total</td>"; }
else { if ($fetch["Region"] == "Oriente") { echo "<td>$total</td>"; } }
}
 
echo "</tr>";
$a = "SELECT * FROM `cantidad de cursos nacional` WHERE Year='2014' ORDER BY Region";
$b = mysqli_query($conexion,$a) or die(mysqli_error($conexion));
 
$y = 0;
while($fetch = mysqli_fetch_assoc($b)){
if ($y < 1) { echo "<tr><td bgcolor='#000066'><span style='color:#fff; font-weight:bold;'>Cursos NI 2014</span>"; }
$y = 1;
$total = $fetch["Enero"] + $fetch["Febrero"] + $fetch["Marzo"] + $fetch["Abril"] + $fetch["Mayo"] + $fetch["Junio"] + $fetch["Julio"] + $fetch["Agosto"] + $fetch["Septiembre"] + $fetch["Octubre"] + $fetch["Noviembre"] + $fetch["Diciembre"];
 
if ($fetch["Region"] === "Andes") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Llanos") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Occidente") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Gran Caracas") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Guayana") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Occidente") { echo "<td>$total</td>"; }
else { if ($fetch["Region"] == "Oriente") { echo "<td>$total</td>"; } }
}
 
echo "</tr>";
$a = "SELECT * FROM `cantidad de cursos nacional` WHERE Year='2015' ORDER BY Region";
$b = mysqli_query($conexion,$a) or die(mysqli_error($conexion));
 
$y = 0;
while($fetch = mysqli_fetch_assoc($b)){
if ($y < 1) { echo "<tr><td bgcolor='#000066'><span style='color:#fff; font-weight:bold;'>Cursos NI 2015</span></td>"; }
$y = 1;
$total = $fetch["Enero"] + $fetch["Febrero"] + $fetch["Marzo"] + $fetch["Abril"] + $fetch["Mayo"] + $fetch["Junio"] + $fetch["Julio"] + $fetch["Agosto"] + $fetch["Septiembre"] + $fetch["Octubre"] + $fetch["Noviembre"] + $fetch["Diciembre"];
 
if ($fetch["Region"] === "Andes") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Llanos") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Centro Occidente") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Gran Caracas") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Guayana") { echo "<td>$total</td>"; }
elseif ($fetch["Region"] == "Occidente") { echo "<td>$total</td>"; }
else { if ($fetch["Region"] == "Oriente") { echo "<td>$total</td>"; } }
}
 
echo "</tr></table>";
?>
</body>
</html>

A ver si a alguien se le ocurre algo mejor...
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 11/11/2015 01:54:58
Hermano eres un master....!!!

Te lo dejo como quedo, y los cálculos dan exactos!!!

Super agradecido Bro!!!


Resultado-con-Tabla
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 11/11/2015 04:06:22
Hermanazo, estoy tratando de modificar el campo "Actualizar" de la primera tabla.


Actualizar-Tabla-01

Logre llamar a la tabla filtrando la región "Andes" pero cuando trato de actualizar el año 2013, 2014 y 2015 de esta misma región, el formulario me trae para actualizar solo el año 2012 en cualquiera de los casos.

Actualizar-Tabla-02

Nota: Estoy utilizando la misma tabla "cantidad de cursos nacional"


Actualizar-Tabla-03

Creo que el problema esta en la clave única la cual es "ID_Cursos"

Actualizar-Tabla-04

Te dejo lo que tengo de 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
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
<?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;
}
}
 
$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 `cantidad de cursos nacional` SET `Year`=%s, Region=%s, Enero=%s, Febrero=%s, Marzo=%s, Abril=%s, Mayo=%s, Junio=%s, Julio=%s, Agosto=%s, Septiembre=%s, Octubre=%s, Noviembre=%s, Diciembre=%s WHERE ID_Curso=%s",
                       GetSQLValueString($_POST['Year'], "date"),
                       GetSQLValueString($_POST['Region'], "text"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString($_POST['ID_Curso'], "text"));
 
  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "../cantcandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
$colname_act = "-1";
if (isset($_GET['Year'])) {
  $colname_act = $_GET['Year'];
}
 
 
mysql_select_db($database_local, $local);
$query_act = "SELECT `Year`, Region, Enero, Febrero, Marzo, Abril, Mayo, Junio, Julio, Agosto, Septiembre, Octubre, Noviembre, Diciembre FROM `cantidad de cursos nacional` WHERE Region='Andes'";
$act = mysql_query($query_act, $local) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de voreno

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (69 intervenciones) el 11/11/2015 12:15:18
Creo que el problema puede estar en el formulario, postea ese código y lo miramos. postea también el código de los botones "actualizar"
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 13/11/2015 03:45:44
Hermano ya logré llamar en el formulario a la Región Andes, el inconveniente que tengo es que aunque haga clic para actualizar en el año 2013, 2014 o 2015, siempre me trae el año y los datos del 2012.

Aquí va el código del formulario

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
<?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;
}
}
 
$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 `cantidad de cursos nacional` SET `Year`=%s, Region=%s, Enero=%s, Febrero=%s, Marzo=%s, Abril=%s, Mayo=%s, Junio=%s, Julio=%s, Agosto=%s, Septiembre=%s, Octubre=%s, Noviembre=%s, Diciembre=%s WHERE `Year`=%s",
 
                       GetSQLValueString($_POST['Region'], "text"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString($_POST['ID_Curso'], "text"),
					   GetSQLValueString($_POST['Year'], "date"));
 
  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "../cantcandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
$colname_act = "-1";
if (isset($_GET['Year'])) {
  $colname_act = $_GET['Year'];
}
 
 
mysql_select_db($database_local, $local);
$query_act = "SELECT * FROM `cantidad de cursos nacional` WHERE Region='Andes'";
 
$act = mysql_query($query_act, $local) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>

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
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="center">
 
    <tr valign="baseline">
      <td nowrap align="right">Año:</td>
      <td><?php echo $row_act['Year']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Región:</td>
      <td><?php echo $row_act['Region']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Enero:</td>
      <td><input type="text" name="Enero" value="<?php echo htmlentities($row_act['Enero'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Febrero:</td>
      <td><input type="text" name="Febrero" value="<?php echo htmlentities($row_act['Febrero'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Marzo:</td>
      <td><input type="text" name="Marzo" value="<?php echo htmlentities($row_act['Marzo'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Abril:</td>
      <td><input type="text" name="Abril" value="<?php echo htmlentities($row_act['Abril'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Mayo:</td>
      <td><input type="text" name="Mayo" value="<?php echo htmlentities($row_act['Mayo'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Junio:</td>
      <td><input type="text" name="Junio" value="<?php echo htmlentities($row_act['Junio'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Julio:</td>
      <td><input type="text" name="Julio" value="<?php echo htmlentities($row_act['Julio'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Agosto:</td>
      <td><input type="text" name="Agosto" value="<?php echo htmlentities($row_act['Agosto'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Septiembre:</td>
      <td><input type="text" name="Septiembre" value="<?php echo htmlentities($row_act['Septiembre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Octubre:</td>
      <td><input type="text" name="Octubre" value="<?php echo htmlentities($row_act['Octubre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Noviembre:</td>
      <td><input type="text" name="Noviembre" value="<?php echo htmlentities($row_act['Noviembre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Diciembre:</td>
      <td><input type="text" name="Diciembre" value="<?php echo htmlentities($row_act['Diciembre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Update record"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="ID_Curso" value="<?php echo $row_act['ID_Curso']; ?>">
    <input type="hidden" name="year" value="<?php echo $row_act['Year']; ?>">
  <input type="hidden" name="Region" value="<?php echo $row_act['Region']; ?>">
</form>


Aquí te dejo el código de formulario "Actualizar"

1
2
3
<td><strong><form action="act_cant_cursos/act_cursos_andes.php?year=<?php echo $row_c_andes['Year']; ?>" method="post">
        <input type="submit" value="Actualizar" style="background-color:#8FB9DA"/> </form></strong>
      </td>
Actualizar-Tabla-01
Actualizar-Tabla-02
Actualizar-Tabla-03
Actualizar-Tabla-04
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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 13/11/2015 10:49:49
El problema esta en que aquí le falta una condición:

1
$query_act = "SELECT * FROM `cantidad de cursos nacional` WHERE Region='Andes'";

Cámbialo por:

1
$query_act = "SELECT * FROM `cantidad de cursos nacional` WHERE Region='Andes' AND Year='$colname_act'";

En el GET tienes Year con la "y" en mayúscula,

1
2
3
4
$colname_act = "-1";
if (isset($_GET['Year'])) {
  $colname_act = $_GET['Year'];
}

Mientras aquí la envías en minúscula:

1
2
3
<td><strong><form action="act_cant_cursos/act_cursos_andes.php?year=<?php echo $row_c_andes['Year']; ?>" method="post">
        <input type="submit" value="Actualizar" style="background-color:#8FB9DA"/> </form></strong>
      </td>

Ponlas en minúscula:

1
2
3
4
$colname_act = "-1";
if (isset($_GET['year'])) {
  $colname_act = $_GET['year'];
}

Y ya creo que te tendría que andar :D
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 18/11/2015 02:06:58
Hola,
todo muy bien, pero cuando trato de actualizar me indica esto:

Warning: sprintf() [function.sprintf]: Too few arguments in C:\AppServ\www\gestion_capacitacion\02_usuario\act_cant_cursos\act_cursos_andes.php on line 55
Query was empty

Te paso el código de esa parte:

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
86
87
88
89
90
91
92
<?php require_once('../../Connections/local.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;
}
}
 
$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 `cantidad de cursos nacional` SET `year`=%s, Region=%s, Enero=%s, Febrero=%s, Marzo=%s, Abril=%s, Mayo=%s, Junio=%s, Julio=%s, Agosto=%s, Septiembre=%s, Octubre=%s, Noviembre=%s, Diciembre=%s WHERE `year`=%s, `Region`=%s",
                       GetSQLValueString($_POST['Region'], "text"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString($_POST['ID_Curso'], "text"),
					   GetSQLValueString($_POST['year'], "date"));
 
  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "../cantcandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
$colname_act = "-1";
if (isset($_GET['year'])) {
  $colname_act = $_GET['year'];
}
 
 
mysql_select_db($database_local, $local);
$query_act = sprintf("SELECT * FROM `cantidad de cursos nacional` WHERE Region='Andes' AND Year='$colname_act'", GetSQLValueString($colname_act, "date"));
$act = mysql_query($query_act, $local) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>
<?php require_once('../../Connections/local.php');
 
session_start(); //INICIO DE SESION USUARIO * IMPORTANTE DEBE IR AL INICIO DE LA PAGINA
?>
<?php //INICIO DE SESION USUARIO (CONTINUA EL INICIO)
require("conexion.php");
$usu=$_SESSION['usuario'];
$consulta11=mysql_query("SELECT * FROM usuario where usuario='$usu' ") or die(mysql_error());
$pacientes=mysql_fetch_array($consulta11);
$usu=$pacientes['nombre']." ".$pacientes['apellido']; //MUESTRA NOMBRE Y APELLIDO DE USUARIO EN EL FRONT
// TERMINA INICIO DE SESION
?>

Ta paso la imagen donde sale la linea que me indica el error:


Actualizar-Tabla-05
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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 18/11/2015 18:01:16
Ummm prueba esto:

1
GetSQLValueString(mysql_real_escape_string($_POST['year']), "date"));

prueba también a escapar con comillas simples todos los %s

1
$updateSQL = sprintf("UPDATE `cantidad de cursos nacional` SET `year`='%s', Region='%s', Enero='%s', Febrero='%s', Marzo='%s', Abril='%s', Mayo='%s', Junio='%s', Julio='%s', Agosto='%s', Septiembre='%s', Octubre='%s', Noviembre='%s', Diciembre='%s' WHERE `year`='%s', `Region`='%s'",
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 18/11/2015 23:19:35
Que va...!

Me sigue indicando lo mismo,

¿A que se deberá?

Actualizar-Tabla-06

Actualizar-Tabla-07

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
<?php require_once('../../Connections/local.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;
}
}
 
$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 `cantidad de cursos nacional` SET `year`='%s', Region='%s', Enero='%s', Febrero='%s', Marzo='%s', Abril='%s', Mayo='%s', Junio='%s', Julio='%s', Agosto='%s', Septiembre='%s', Octubre='%s', Noviembre='%s', Diciembre='%s' WHERE `year`='%s', `Region`='%s'",
                       GetSQLValueString($_POST['year'], "date"),
					   GetSQLValueString($_POST['Region'], "text"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString(mysql_real_escape_string($_POST['year']), "date"));
 
  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "../cantcandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
$colname_act = "-1";
if (isset($_GET['year'])) {
  $colname_act = $_GET['year'];
}
 
 
mysql_select_db($database_local, $local);
$query_act = sprintf("SELECT * FROM `cantidad de cursos nacional` WHERE Region='Andes' AND Year='$colname_act'", GetSQLValueString($colname_act, "date"));
$act = mysql_query($query_act, $local) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>
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
Imágen de perfil de voreno

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (69 intervenciones) el 18/11/2015 23:47:55
Fíjate que GetSQLValueString($_POST['year'], "date") lo estas enviando dos veces.
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 18/11/2015 23:56:26
Tienes toda la razón,

Pero que va, lo quite y sigue aun.
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
Imágen de perfil de voreno

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (69 intervenciones) el 18/11/2015 23:57:05
como tienes el código ahora?
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 19/11/2015 00:00:44
El mismo pero sin esa linea:

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
<?php require_once('../../Connections/local.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;
}
}
 
$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 `cantidad de cursos nacional` SET `year`='%s', Region='%s', Enero='%s', Febrero='%s', Marzo='%s', Abril='%s', Mayo='%s', Junio='%s', Julio='%s', Agosto='%s', Septiembre='%s', Octubre='%s', Noviembre='%s', Diciembre='%s' WHERE `year`='%s', `Region`='%s'",
					   GetSQLValueString($_POST['Region'], "text"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString(mysql_real_escape_string($_POST['year']), "date"));
 
  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "../cantcandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
$colname_act = "-1";
if (isset($_GET['year'])) {
  $colname_act = $_GET['year'];
}
 
 
mysql_select_db($database_local, $local);
$query_act = sprintf("SELECT * FROM `cantidad de cursos nacional` WHERE Region='Andes' AND Year='$colname_act'", GetSQLValueString($colname_act, "date"));
$act = mysql_query($query_act, $local) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>
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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 19/11/2015 00:19:36
Me huele a que la variable $_POST['year'] esta vacía

Recuerdas anteriormente que hubo problemas con la "Y" que la tenias en mayúscula? asegúrate de que el formulario que envías mediante post lo tengas en minúscula.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 19/11/2015 00:28:18
o mejor aun, pon la y en mayúscula, solo de esa variable, el otro dia te indique que pusieras en minúscula la variable $_GET['Year'] pero ahora me he fijado que también pusiste en minúscula la variable $_POST['Year'] . ese es el fallo. deja la variable $_POST tal como estaba
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 19/11/2015 01:15:48
Con respecto a eso cambie todo a year en minúscula desde la Base de datos hasta los códigos:


Actualizar-Tabla-08

Actualizar-Tabla-09


Codigo de lo que envio para llegar al fomulario actualizar:

1
2
<td><strong><form action="act_cant_cursos/act_cursos_andes.php?year=<?php echo $row_c_andes['year']; ?>" method="post">
        <input type="submit" value="Actualizar" style="background-color:#8FB9DA"/> </form></strong>
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 19/11/2015 01:17:20
Codigo para el formulario actualizar:

Actualizar-Tabla-10


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
86
87
88
89
90
91
<?php require_once('../../Connections/local.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;
}
}
 
$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 `cantidad de cursos nacional` SET `year`='%s', Region='%s', Enero='%s', Febrero='%s', Marzo='%s', Abril='%s', Mayo='%s', Junio='%s', Julio='%s', Agosto='%s', Septiembre='%s', Octubre='%s', Noviembre='%s', Diciembre='%s' WHERE `year`='%s', `Region`='%s'",
					   GetSQLValueString($_POST['Region'], "text"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString(mysql_real_escape_string($_POST['year']), "date"));
 
  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "../cantcandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
$colname_act = "-1";
if (isset($_GET['year'])) {
  $colname_act = $_GET['year'];
}
 
 
mysql_select_db($database_local, $local);
$query_act = sprintf("SELECT * FROM `cantidad de cursos nacional` WHERE Region='Andes' AND year='$colname_act'", GetSQLValueString($colname_act, "date"));
$act = mysql_query($query_act, $local) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>
<?php require_once('../../Connections/local.php');
 
session_start(); //INICIO DE SESION USUARIO * IMPORTANTE DEBE IR AL INICIO DE LA PAGINA
?>
<?php //INICIO DE SESION USUARIO (CONTINUA EL INICIO)
require("conexion.php");
$usu=$_SESSION['usuario'];
$consulta11=mysql_query("SELECT * FROM usuario where usuario='$usu' ") or die(mysql_error());
$pacientes=mysql_fetch_array($consulta11);
$usu=$pacientes['nombre']." ".$pacientes['apellido']; //MUESTRA NOMBRE Y APELLIDO DE USUARIO EN EL FRONT
// TERMINA INICIO DE SESION
?>
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 19/11/2015 01:17:49
Codigo del formulario.

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
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="center">
 
    <tr valign="baseline">
      <td nowrap align="right">Año:</td>
      <td><?php echo $row_act['year']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Región:</td>
      <td><?php echo $row_act['Region']; ?></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Enero:</td>
      <td><input type="text" name="Enero" value="<?php echo htmlentities($row_act['Enero'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Febrero:</td>
      <td><input type="text" name="Febrero" value="<?php echo htmlentities($row_act['Febrero'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Marzo:</td>
      <td><input type="text" name="Marzo" value="<?php echo htmlentities($row_act['Marzo'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Abril:</td>
      <td><input type="text" name="Abril" value="<?php echo htmlentities($row_act['Abril'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Mayo:</td>
      <td><input type="text" name="Mayo" value="<?php echo htmlentities($row_act['Mayo'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Junio:</td>
      <td><input type="text" name="Junio" value="<?php echo htmlentities($row_act['Junio'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Julio:</td>
      <td><input type="text" name="Julio" value="<?php echo htmlentities($row_act['Julio'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Agosto:</td>
      <td><input type="text" name="Agosto" value="<?php echo htmlentities($row_act['Agosto'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Septiembre:</td>
      <td><input type="text" name="Septiembre" value="<?php echo htmlentities($row_act['Septiembre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Octubre:</td>
      <td><input type="text" name="Octubre" value="<?php echo htmlentities($row_act['Octubre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Noviembre:</td>
      <td><input type="text" name="Noviembre" value="<?php echo htmlentities($row_act['Noviembre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Diciembre:</td>
      <td><input type="text" name="Diciembre" value="<?php echo htmlentities($row_act['Diciembre'], ENT_COMPAT, 'utf-8'); ?>" size="32"></td>
    </tr>
  </table>
 
     <table align="center">
  	<tr align="center">
   		<td align="center"><input type="submit" value="Actualizar"></td>
        <td width="40px"><ul>&nbsp;</ul></td>
		<td align="left"><input type="submit" value="Regresar"></td>
    </tr>
   </table>
 
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="ID_Curso" value="<?php echo $row_act['ID_Curso']; ?>">
    <input type="hidden" name="year" value="<?php echo $row_act['year']; ?>">
  <input type="hidden" name="Region" value="<?php echo $row_act['Region']; ?>">
</form>
 
<p align="center">Gerencia de Capacitación ®</p>
 
 
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($act);
?>
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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 19/11/2015 09:51:06
Antes del update haz echo $_POST['year']; a ver si es que esta vació.
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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 19/11/2015 09:53:17
Me acabo de fijar que en la base de datos el campo year es del tipo year y en el código le indicas que es del tipo date:

GetSQLValueString(mysql_real_escape_string($_POST['year']), "date"));
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 20/11/2015 02:44:42
Hermano que va, nada que avanza cuando le doy actualizar en el formulario, el rollo lo veo en la función,

Warning: sprintf() [function.sprintf]: Too few arguments in C:\AppServ\www\gestion_capacitacion\02_usuario\act_cant_cursos\act_cursos_andes.php on line 54
Query was empty

De hecho si quito el $_POST['year']; igual me sigue dado error al terminar esa 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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 20/11/2015 10:53:29
Vale, haz una cosa, creo que es por el orden year lo tienes abajo del todo y en el SET lo tienes primero prueba así:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$updateSQL = sprintf("UPDATE `cantidad de cursos nacional` SET `year`='%s', Region='%s', Enero='%s', Febrero='%s', Marzo='%s', Abril='%s', Mayo='%s', Junio='%s', Julio='%s', Agosto='%s', Septiembre='%s', Octubre='%s', Noviembre='%s', Diciembre='%s' WHERE `year`='%s', `Region`='%s'",
                       GetSQLValueString($_POST['year']), "year"),
		       GetSQLValueString($_POST['Region'], "text"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"));

Si no es el problema, nada mas veo hacer el update sin utilizar sprintf ya que da muchos problemas... no le veo ningún fallo mas al 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

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (33 intervenciones) el 20/11/2015 10:56:49
cuando quitaste GetSQLValueString($_POST['year']), "year") también lo quitaste del set? si no lo hiciste por eso mismo te seguía dando error...
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 22/11/2015 04:50:57
Hermano he probado en hacer nuevamente el código nuevamente y observo que el problema esta en el WHERE

WHERE `year`='%s', `Region`='%s'",

Lo modifique de esta manera:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$updateSQL = sprintf("UPDATE `cantidad de cursos nacional` SET ID_Curso=%s, `year`=%s, Enero=%s, Febrero=%s, Marzo=%s, Abril=%s, Mayo=%s, Junio=%s, Julio=%s, Agosto=%s, Septiembre=%s, Octubre=%s, Noviembre=%s, Diciembre=%s WHERE `year`='%s'",
                       GetSQLValueString($_POST['ID_Curso'], "text"),
                       GetSQLValueString($_POST['year'], "date"),
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString($_POST['Region'], "text"));

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "../cantcandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
 
$colname_act = "-1";
if (isset($_GET['year'])) {
  $colname_act = $_GET['year'];
}
 
 
mysql_select_db($database_local, $local);
$query_act = sprintf("SELECT * FROM `cantidad de cursos nacional` WHERE `Region`='Andes' AND `year`='$colname_act'", GetSQLValueString($colname_act, "year"));
$act = mysql_query($query_act, $local) or die(mysql_error());
$row_act = mysql_fetch_assoc($act);
$totalRows_act = mysql_num_rows($act);
?>

Y ahora me dica esto:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Andes''' at line 1
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
Imágen de perfil de voreno

Suma Filas y Columnas Mysql + PHP

Publicado por voreno (69 intervenciones) el 22/11/2015 12:07:45
Acabo de hacer pruebas... con esto me ha echo el update:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$updateSQL = sprintf("UPDATE `cantidad de cursos nacional` SET Enero='%s', Febrero='%s', Marzo='%s', Abril='%s', Mayo='%s', Junio='%s', Julio='%s', Agosto='%s', Septiembre='%s', Octubre='%s', Noviembre='%s', Diciembre='%s' WHERE `year`='%s' AND Region='%s'",
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
		       GetSQLValueString($_POST['year'], "year"),
                       GetSQLValueString($_POST['Region'], "varchar"));
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 22/11/2015 15:36:05
Hermano la verdad eres un Capo....!!!!!

Ya esta listo, mil gracias por tu apoyo....!!!
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 11/12/2015 21:13:45
Hermano, como estas?

Estoy intentando hacer lo mismo con con otra tabla, ya logre hacer todo lo anterio, pero al intentar actualizar no lo hace en la DB, no se si tiene que ver con la clave primaria o con el filtro que le estoy colocando al llamado de la base de datos,

Te envío el código para que lo veas y las imágenes (como adjunto)


Código del Formulario Actualizar:

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
$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 `gcni nacional` SET `year`='%s', Region='%s', Enero='%s', Febrero='%s', Marzo='%s', Abril='%s', Mayo='%s', Junio='%s', Julio='%s', Agosto='%s', Septiembre='%s', Octubre='%s', Noviembre='%s', Diciembre='%s' WHERE ID_Curso='%s'",
                       GetSQLValueString($_POST['Enero'], "int"),
                       GetSQLValueString($_POST['Febrero'], "int"),
                       GetSQLValueString($_POST['Marzo'], "int"),
                       GetSQLValueString($_POST['Abril'], "int"),
                       GetSQLValueString($_POST['Mayo'], "int"),
                       GetSQLValueString($_POST['Junio'], "int"),
                       GetSQLValueString($_POST['Julio'], "int"),
                       GetSQLValueString($_POST['Agosto'], "int"),
                       GetSQLValueString($_POST['Septiembre'], "int"),
                       GetSQLValueString($_POST['Octubre'], "int"),
                       GetSQLValueString($_POST['Noviembre'], "int"),
                       GetSQLValueString($_POST['Diciembre'], "int"),
                       GetSQLValueString($_POST['ID_Curso'], "varchar"),
					   GetSQLValueString($_POST['year'], "year"),
                       GetSQLValueString($_POST['Region'], "varchar"));
 
  mysql_select_db($database_local, $local);
  $Result1 = mysql_query($updateSQL, $local) or die(mysql_error());
 
  $updateGoTo = "gcniandes.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
 
$colname_gcni2015 = "-1";
if (isset($_GET['Region'])) {
  $colname_gcni2015 = $_GET['Region'];
}
 
mysql_select_db($database_local, $local);
$query_gcni2015 = sprintf("SELECT * FROM `gcni nacional` WHERE `Region`= 'Andes'", GetSQLValueString($colname_gcni2015, "Region"));
$gcni2015 = mysql_query($query_gcni2015, $local) or die(mysql_error());
$row_gcni2015 = mysql_fetch_assoc($gcni2015);
$totalRows_gcni2015 = mysql_num_rows($gcni2015);
?>



El formulario (Form)


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
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
 
<table border="1" align="center" bgcolor="#FFFFFF" width="1280">
  <tr bgcolor="#E0E0E0" align="center" height="30">
 
    <td width="280" height="25"><strong>Indicador</strong></td>
    <td><strong>Año</strong></td>
    <td><strong>Region</strong></td>
    <td><strong>CDS</strong></td>
    <td><strong>Ene</strong></td>
    <td><strong>Feb</strong></td>
    <td><strong>Mar</strong></td>
    <td><strong>Abr</strong></td>
    <td><strong>May</strong></td>
    <td><strong>Jun</strong></td>
    <td><strong>Jul</strong></td>
    <td><strong>Ago</strong></td>
    <td><strong>Sep</strong></td>
    <td><strong>Oct</strong></td>
    <td><strong>Nov</strong></td>
    <td><strong>Dic</strong></td>
 
  </tr>
 
 
 
  <?php do { ?>
    <tr align="center" height="20" >
      <td bgcolor="#E0E0E0" align="left"><?php echo $row_gcni2015['Id'];  ?>&nbsp; </td>
      <td><?php echo $row_gcni2015['year']; ?>&nbsp; </td>
      <td><?php echo $row_gcni2015['Region']; ?>&nbsp; </td>
      <td><?php echo $row_gcni2015['CDS']; ?>&nbsp;</td>
      <td><input type="text" name="Enero" value="<?php echo htmlentities($row_gcni2015['Enero'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Febrero" value="<?php echo htmlentities($row_gcni2015['Febrero'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Marzo" value="<?php echo htmlentities($row_gcni2015['Marzo'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Abril" value="<?php echo htmlentities($row_gcni2015['Abril'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Mayo" value="<?php echo htmlentities($row_gcni2015['Mayo'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Junio" value="<?php echo htmlentities($row_gcni2015['Junio'], ENT_COMPAT, 'utf-8'); ?>" size="1"> </td>
      <td><input type="text" name="Julio" value="<?php echo htmlentities($row_gcni2015['Julio'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Agosto" value="<?php echo htmlentities($row_gcni2015['Agosto'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Septiembre" value="<?php echo htmlentities($row_gcni2015['Septiembre'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Octubre" value="<?php echo htmlentities($row_gcni2015['Octubre'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Noviembre" value="<?php echo htmlentities($row_gcni2015['Noviembre'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
      <td><input type="text" name="Diciembre" value="<?php echo htmlentities($row_gcni2015['Diciembre'], ENT_COMPAT, 'utf-8'); ?>" size="1"></td>
 
    </tr>
 
    <?php } while ($row_gcni2015 = mysql_fetch_assoc($gcni2015)); ?>
 
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table>
    <tr valign="baseline">
      <td nowrap align="center">&nbsp;</td>
      <td><input type="submit" value="Actualizar registro"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="ID_Curso" value="<?php echo $row_gcni2015['ID_Curso']; ?>">
</form>
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
Imágen de perfil de Robinson

Suma Filas y Columnas Mysql + PHP

Publicado por Robinson (41 intervenciones) el 16/12/2015 21:12:42
Buenas,

Amigos, necesito de su acostumbrado apoyo en la ultima consulta realizada, creo que el problema esta en la siguiente linea, pues cuando le coloco esto
1
='$colname_act'
me da error:

$query_gcni2015 = sprintf("SELECT * FROM `gcni nacional` WHERE `Region`= 'Andes'", GetSQLValueString($colname_gcni2015, "Region"));

Agradecido por el apoyo,
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
Imágen de perfil de Martin
Val: 64
Ha aumentado su posición en 3 puestos en PHP (en relación al último mes)
Gráfica de PHP

Suma Filas y Columnas Mysql + PHP

Publicado por Martin (32 intervenciones) el 04/02/2018 00:06:41
Podrian subir el resultado final del proyecto, el codigo. Buena idea
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