
Actualizar contenido de una Tabla, PHP y MSQL
Publicado por Robinson (41 intervenciones) el 30/11/2015 03:00:19
Buenas amigos gusto en saludarles,
Vengo por acá buscando del apoyo de ustedes:
Tengo esta tabla y quisiera poder actualizar los registros de la misma:

Esta tabla la estoy llamando y filtrando por regiones, en este caso solo estoy llamando a la region Andes

Como los comento, quisiera poder actualizar los datos, seria ideal que fuera en otra pagina o no se que pueden sugerir ustedes,
Les dejo parte del código
El front:
Vengo por acá buscando del apoyo de ustedes:
Tengo esta tabla y quisiera poder actualizar los registros de la misma:

Esta tabla la estoy llamando y filtrando por regiones, en este caso solo estoy llamando a la region Andes

Como los comento, quisiera poder actualizar los datos, seria ideal que fuera en otra pagina o no se que pueden sugerir ustedes,
Les dejo parte del 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
<?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;
}
}
$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, "text"));
$gcni2015 = mysql_query($query_gcni2015, $local) or die(mysql_error());
$row_gcni2015 = mysql_fetch_assoc($gcni2015);
$totalRows_gcni2015 = mysql_num_rows($gcni2015);
?>
<?php
El front:
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
<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>Enero</strong></td>
<td><strong>Febrero</strong></td>
<td><strong>Marzo</strong></td>
<td><strong>Abril</strong></td>
<td><strong>Mayo</strong></td>
<td><strong>Junio</strong></td>
<td><strong>Julio</strong></td>
<td><strong>Agosto</strong></td>
<td><strong>Septiembre</strong></td>
<td><strong>Octubre</strong></td>
<td><strong>Noviembre</strong></td>
<td><strong>Diciembre</strong></td>
</tr>
<?php do { ?>
<tr align="center" height="20" >
<td bgcolor="#E0E0E0" align="left"><?php echo $row_gcni2015['Id']; ?> </td>
<td><?php echo $row_gcni2015['year']; ?> </td>
<td><?php echo $row_gcni2015['Region']; ?> </td>
<td><?php echo $row_gcni2015['CDS']; ?> </td>
<td><?php echo $row_gcni2015['Enero']; ?> </td>
<td><?php echo $row_gcni2015['Febrero']; ?> </td>
<td><?php echo $row_gcni2015['Marzo']; ?> </td>
<td><?php echo $row_gcni2015['Abril']; ?> </td>
<td><?php echo $row_gcni2015['Mayo']; ?> </td>
<td><?php echo $row_gcni2015['Junio']; ?> </td>
<td><?php echo $row_gcni2015['Julio']; ?> </td>
<td><?php echo $row_gcni2015['Agosto']; ?> </td>
<td><?php echo $row_gcni2015['Septiembre']; ?> </td>
<td><?php echo $row_gcni2015['Octubre']; ?> </td>
<td><?php echo $row_gcni2015['Noviembre']; ?> </td>
<td><?php echo $row_gcni2015['Diciembre']; ?> </td>
</tr>
<?php } while ($row_gcni2015 = mysql_fetch_assoc($gcni2015)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($gcni2015);
?>
Valora esta pregunta


0