Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/10/2005, 02:03
Avatar de jerkan
jerkan
 
Fecha de Ingreso: septiembre-2005
Mensajes: 1.607
Antigüedad: 18 años, 7 meses
Puntos: 19
Cita:
Iniciado por sevastian
<?php
echo"<html>\n";
echo"<head>\n";
echo"<title>listar</title>\n";
echo"</head>\n";
session_start();
session_register('LOGIN');
$LOGIN;

$enlace = mysql_connect("localhost", "root", "")or die("No pudo conectarse : " . mysql_error());
//echo "Conexi&oacute;n exitosa";
mysql_select_db("hospital") or die("No pudo seleccionarse la BD.");

$consulta = "SELECT usuario.ID_USUARIO,usuario.ID_GRUPO,usuario.NOMBRE ,usuario.APELLIDO,usuario.LOGIN,usuario.PAS
from usuario
inner join GRUPO on usuario.ID_GRUPO=GRUPO.ID_GRUPO ORDER BY usuario.ID_USUARIO DESC";
// COMO LO AGO PARA QUE ME TIRE LOS ID_USARIO DEL MAS GRANDE AL MAS CHICO.

echo"res=$res";
$res = mysql_query($consulta) or die("La consulta fall&oacute;: " . mysql_error());
$num=mysql_numrows($res);
mysql_close();
echo"<body>\n";
$semasforo=FALSE;
echo"<center><h2>LISTADO DE USUARIOS<b></b></h2></center>\n";
echo"<center>\n";
echo"<table border='0' width='750'>\n";
echo"<tr bgcolor='#0099FF'>\n";
echo"<td width='80' align='center'><b>ID_USUARIO</b></td>\n";
echo"<td width='160' align='center'><b>GRUPO</b></td>\n";
echo"<td width='160' align='center'><b>NOMBRE</b></td>\n";
echo"<td width='180' align='center'><b>APELLIDO</b></td>\n";
echo"<td width='80' align='center'><b>LOGIN</b></td>\n";
echo"<td width='80' align='center'><b>PAS</b></td>\n";


echo"<tr>\n";

$i=0;
while ($i < $num) {
if ($semasforo)
{
$color="#99CCFF";
}
else
{
$color="#66FFFF";
}

$id_usuario=mysql_result($res,$i,"ID_USUARIO");
$id_grupo=mysql_result($res,$i,"ID_GRUPO");
$nombre=mysql_result($res,$i,"NOMBRE");
$apellido=mysql_result($res,$i,"APELLIDO");
$login=mysql_result($res,$i,"LOGIN");
$pas=mysql_result($res,$i,"PAS");




echo"<tr bgcolor=$color>\n";
echo"<td>$nombre</td>";// AQUI COMO AGO PARA Q APARESCA EL NOMBRE DEL GRUPO DE USUARIO NO EL NUMERO DEL GRUPO TENGO DOS TABLAS USUARIO.ID_GRUPO Y GRUPO.ID Y GRUPO.NOMBRE
echo"<td>$id_grupo</td>" ;
echo"<td>$nombre</td>" ;
echo"<td>$apellido</td>";
echo"<td><center>$login</center></td>";
echo"<td>$pas</td>";

echo"<tr>\n";
$i++;
$semasforo=!$semasforo;
}
echo"</table>\n";
echo"</center>\n";
echo"<form action='agregarusuario.php' method='post' name=''>\n";
echo"<center>\n";
echo"<table border='0'>\n";
echo"<tr>\n";
echo"<td width='100%' height='19' colspan='2'> <p align='center'>\n";
echo"<input type='submit' value='Insertar' name='btninsertar'>\n";
echo"</td>\n";
echo"</tr>\n";
echo"</table>\n";
echo"</center>\n";
echo"</form>\n";

/* Liberar conjunto de resultados */
//mysql_free_result($res);

echo"</body>\n";
echo"</html>\n";
?>

gracias de ante mano