PHP - Problema al mostrar información de base de datos.

 
Vista:
sin imagen de perfil

Problema al mostrar información de base de datos.

Publicado por José Alberto (17 intervenciones) el 14/11/2016 21:12:22
Buenas tardes.

Estoy trabajando con PHP y PostgreSQL.
Estoy intentando hacer un UPDATE a la base de datos a través de una tabla, la cual contiene 3 input, ID, Nombre y Correo.
Hasta ahora ya pude hacer que los datos se actualicen en la base de datos, pero para que en mi página se muestren los datos actualizados tengo que refrescar 1 o 2 veces el navegador.

¿Alguien me puede echar una mano con lo que debería hacer?

Dejo mi 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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
	<link rel="shortcut icon" href="favicons.png" type="image/png" />
	<link type="text/css" href="boton.css" rel="stylesheet"/>
	<link type="text/css" href="boton2.css" rel="stylesheet"/>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>UAEM - Universidad Aut&oacuteónoma del Estado de Morelos</title>
	<p align="center"><IMG SRC="banner.png" /></p>
 
	<script type="text/javascript">
 
	function mostrarAdmin(){
		document.getElementById('hAdmin').style.display= 'block';
	}
	</script>
</head>
 
 
<?php
 
	include("seguridadAdmin.php");
	include("funciones.php");
	include("conexion.php");
	$conn = pg_connect ($cad) or die ("Error al conectar");
	header ("Cache-Control: no-cache, must-revalidate"); //no guardar en CACHE 
	header ("Pragma: no-cache"); //PARANOIA, NO GUARDAR EN CACHE 
 
?>
 
<html>
 
	<body link="#ffffff" vlink="#ffffff">
		<form>
	<?php
	include("conexion.php");
	$consulta="SELECT * FROM login where tipo='admin'";
	$resultadoConsulta=pg_query($consulta) or die ("Error");
 
	?>
 
			<link rel="stylesheet" href="Style.css"/>
 
			<a href="menuA.php" class="myButton">Usuarios</a>
			<a href="#" class="myButton" onclick="mostrarAdmin()">Admin</a>
			<a href="muestraEncuesta.php" class="myButton">Encuestas</a>
 
 
<br><br><div id='hAdmin' style='display:none;'>
 
			 <a href="#" class="btnMostrar" onclick="document.getElementById('hAdmin1').style.visibility='visible'
			 	if(this.parentNode.getElementsByTagName('div')[0].style.display != '')
 				{
 					this.parentNode.getElementsByTagName('div')[0].style.display = '';
 				} else { this.parentNode.getElementsByTagName('div')[0].style.display = 'none';}" type="button">Consultar Usuarios</a>


			 <a href="#" class="btnModificar" onclick="document.getElementById('hAdmin2').style.visibility='visible';
			 if(this.parentNode.getElementsByTagName('div')[1].style.display != '')
 				{
 					this.parentNode.getElementsByTagName('div')[1].style.display = '';
 				} else { this.parentNode.getElementsByTagName('div')[1].style.display = 'none';}" type="button">Modificar Usuarios</a>


			 <a href="#" class="btnAgregar" onclick="document.getElementById('hAdmin3').style.visibility='visible';
			 if(this.parentNode.getElementsByTagName('div')[2].style.display != '')
 				{
 					this.parentNode.getElementsByTagName('div')[2].style.display = '';
 				} else { this.parentNode.getElementsByTagName('div')[2].style.display = 'none';}" type="button">Agregar Usuarios</a>


			 <a href="#" class="btnElimina" onclick="document.getElementById('hAdmin4').style.visibility='visible';
			 if(this.parentNode.getElementsByTagName('div')[3].style.display != '')
 				{
 					this.parentNode.getElementsByTagName('div')[3].style.display = '';
 				} else { this.parentNode.getElementsByTagName('div')[3].style.display = 'none';}" type="button">Eliminar Usuarios</a>

			 <div id='hAdmin1' style='visibility:hidden'>

			 <br><?php if($consulta) { ?>
			 <table BORDER="2px" BORDERCOLOR="#0F47B0" CELLPADDING="2" CELLSPACING="2" WIDTH="30%" align="center">
			 <tr>
			 	<th>ID</th>
			 	<th>Nombre</th>
			 	<th>Correo</th>
			 	<th>Rol</th>
			 </tr>
			 

			 <?php while ($imprime=pg_fetch_assoc($resultadoConsulta)){ ?>
			 <tr>
			 <td><?php echo $imprime[id];?></td>  
     		 <td><?php echo $imprime[nombre];?></td>  
     		 <td><?php echo $imprime[correo];?></td>   
     		 <td><?php echo $imprime[tipo];?></td>
			 </tr>
			 <?php }?>
			 </table>

			 <?php } else{?>
			 <p>No hay datos.</p>
			 <?php }?>
			</div>


<form href="admin.php" name="registros" method="post">
			<div id="hAdmin2" style='visibility: hidden;'>
			<table BORDER="2px" BORDERCOLOR="#0F47B0" CELLPADDING="2" CELLSPACING="2" WIDTH="30%" align="center">
			 		<th colspan="2">MODIFICAR USUARIO</th>
			 		<tr>	<td>ID</td>	<td><input type="text" id="idActualiza" name="idActualiza" /></td></tr>
					<tr>	<td>Nombre</td>	<td><input type="text" id="nombreActualiza" name="nombreActualiza" /></td></tr>
					<tr>	<td>Correo</td>	<td><input type="text" id="correoActualiza" name="correoActualiza" /></td></tr>
					<tr>	<td colspan="2"><input type="submit" value="ACTUALIZAR DATOS" /></button></td></tr>
			</table>
			</div>

			<?php
			include("conexion.php");
$modificaID=$_GET['idActualiza'];
$modificaNombre=$_GET['nombreActualiza'];
$modificaCorreo=$_GET['correoActualiza'];

$modificarDatos="UPDATE login SET nombre='$modificaNombre' , correo='$modificaCorreo' WHERE id='$modificaID'";
$resultadosActualiza=pg_query($modificarDatos);
?>
 
			<div id="hAdmin3" style='visibility: hidden;'>
			<table BORDER="2px" BORDERCOLOR="#0F47B0" CELLPADDING="2" CELLSPACING="2" WIDTH="30%" align="center">
					<th colspan="2">AGREGAR USUARIO</th>
					<tr>	<td>ID</td>	<td><input type="text" id="agregaID"/></td></tr>
					<tr>	<td>Nombre</td>	<td><input type="text" id="agregaNombre"/></td></tr>
					<tr>	<td>Correo</td>	<td><input type="text" id="agregaCorreo"/></td></tr>
					<tr>	<td>Rol</td><td><input type="text" id="agregaRol"/></td></tr>
					<tr>	<td colspan="2"><button>AGREGAR USUARIOS</button></td></tr>
			</table>
			</div>
 
			<div id="hAdmin4" style='visibility: hidden;'>
			<table BORDER="2px" BORDERCOLOR="#0F47B0" CELLPADDING="2" CELLSPACING="2" WIDTH="30%" align="center">
					<th colspan="2">ELIMINAR  USUARIO</th>
					<tr>	<td>ID</td>	<td><input type="text" id="eliminaID"/></td></tr>
					<tr>	<td>Nombre</td>	<td><input type="text" id="eliminaNombre"/></td></tr>
					<tr>	<td>Correo</td>	<td><input type="text" id="eliminaCorreo"/></td></tr>
					<tr>	<td>Rol</td><td><input type="text" id="eliminaRol"/></td></tr>
					<tr>	<td colspan="2"><button>ELIMINAR USUARIOS</button></td></tr>
			</table>
			</div>
</form>
			</div>
 
 
		<footer>
			<div class='define'>
			<table width="100%" >
				<th>Contacto</th>
 
				<th>Redes Sociales</th>
				<tr>
					<td >Direcci&oacuten: Av. Universidad No. 1001, Col Chamilpa, <br>Cuernavaca, Morelos, M&eacutexico. C.P. 62209<br>
						Tel&eacutefono: (777) 329-79-00<br>
						<a href="mailto:web@uaem.mx">Email: web@uaem.mx</a>
					</td>
 
					<td>
						<a href="https://www.facebook.com/UAEM.OFICIAL/" target="nueva" class="boton">S&iacuteguenos en Facebook</a>
						<a href="https://twitter.com/uaemorelos" class="twitter-follow-button" data-show-count="false">Síguenos en @uaemorelos</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
						<script src="https://apis.google.com/js/platform.js"></script>
						<div class="g-ytsubscribe" data-channel="UAEMor" data-layout="default" data-count="default"></div>
					</td>
				</tr>
			</table>
			</div>
			<a href="finSesionAdmin.php" class="btnCerrar">Cerrar Sesi&oacuten</a>
		</footer>
		</form>
	</body>
</html>
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
sin imagen de perfil
Val: 21
Ha aumentado su posición en 3 puestos en PHP (en relación al último mes)
Gráfica de PHP

Problema al mostrar información de base de datos.

Publicado por Andres (10 intervenciones) el 15/11/2016 15:20:13
Si no resolvíste todavía, manda el archivo y una copia de tu db en texto plano para probar y ver cual es el problema.
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

Problema al mostrar información de base de datos.

Publicado por Lawliet (351 intervenciones) el 15/11/2016 18:10:10
O podías comentar cual es el error que te aparece y así darte una solución más cercana a tu problema.
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