Ver Mensaje Individual
  #4 (permalink)  
Antiguo 13/02/2008, 09:23
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Problema con funcion

Lo que deberías de hacer (para no hacer múltiples consultas) es directamente:
Código PHP:
function sexo($valor)
    {

    if(
$valor == "0")
        {
        return 
"NA";
        }
        else
        {
        if(
$valor == "1")
            {
            return 
"Masculino";
            }
            else
            {
            if(
$valor == "2")
                {
                return 
"Femenino";
                }
            }
        }
    } 
y le pasas el valor en tu while:
Código PHP:
$r mysql_query("SELECT * FROM ranking ORDER BY id DESC");

while(
$row mysql_fetch_array($rMYSQL_ASSOC))
{

echo 
'
        <TR>
                <td>'
.$row["Id"].'</td>
                <td>'
.$row["usuario"].'</td>
                <td>'
.$row["email"].'</td>
                <td>'
.$row["equipo"].'</td>
                <td>'
.sexo($row['sexo']).'</td>
                <td>'
.$row["nacionalidad"].'</td>
        </TR>
        '
;

Saludos.