hacer un select con una variable
Publicado por cristian (1 intervención) el 06/12/2016 04:57:39
/// Hola a todos, necesito saber cual es error de lo siguiente. El usuario se loguea y guardo el nombre del usuario en una variable session, lo que tengo en esa variable session lo guardo en otra variable $var, para poder hacer un SELECT y traer datos relacionados, el tema es que no me muestra los datos en pantalla si pongo $var, pero si pongo un nombre en especifico, si los trae.. y la variable si está guardando el dato, no logro entender porque no muestra los datos!! gracias!
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
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="formato.css">
<head>
<title>Dogo Crossfit</title>
</head>
<body background="imagenes/fondo2.jpg" link= "black" onload="nobackbutton();" class= "tipoLetra">
<table align="center" width="100%" border="0">
<tr>
<td align="lefht">
<img src= "imagenes/logoDogo.jpg" class= "imagen">
<font color="white" size= "6">Hola
<?php session_start();
echo $_SESSION['usuario'];
$var=$_SESSION['usuario'];
?>
</font>
</td>
<td align="right">
<a href= "usuarios.php">Cerrar sesión</a>
</td>
</tr>
<tr>
<td colspan="2">
<font color="white" size= "6">Funciones:
<a href= "alumnoInscripcionClases.php">Inscripción a clases</a> -
<a href= "alumnoCreditosDisp.php">Créditos disponibles</a> -
<a href= "alumnoWod.php">Wod</a>
</font>
</td>
</tr>
<tr>
<td colspan="2">
<img src="imagenes/peligro.jpg" width="100%" height="6px">
</td>
</tr>
<tr>
<td>
</td>
<td >
<?Php
require ("conexion.php");
$conexion=retornarConexion();
/* Se comienza la lista*/
echo $var;
$registro= mysql_query("select nombre,creditos,cuota,creditoVencimiento from alumnos
where nombre= '".$var."'", $conexion) or die (mysql_error());
echo "<table border= '3' cellpadding= '4' class='listaActividades'><caption><font color='white'>Control de Créditos</font></caption>";
echo "<tr>";
echo "<th>Nombre</th><th>Créditos disponibles</th><th>Mes abonado</th><th>Vencimiento de los créditos</th>";
echo "</tr>";
while($reg= mysql_fetch_array($registro))
{
echo "<tr>";
echo "<td>";
echo $reg['nombre'];
echo "</td>";
echo "<td>";
echo $reg['creditos'];
echo "</td>";
echo "<td>";
echo $reg['cuota'];
echo "</td>";
echo "<td>";
echo $reg['creditoVencimiento'];
echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
</td>
</tr>
</table>
</body>
</html>
Valora esta pregunta


0