Page 1 of 1

Gender icon

Posted: Sat Jan 30, 2010 7:55 am
by riiel
How to do this: If user is male than male icon front of username and if user is female than female icon
mysql table "users" row "gender" Male=1 & Female=2

Code: Select all

<a href="?uID=<?=$users->getCurUid();?>"><b>
              <?=$users->getUsername($users->getCurUid());?>
Like:
Image Phil
Image Sandy

Understand me ? :)

Re: Gender icon

Posted: Sat Jan 30, 2010 9:19 am
by requinix
This is really basic PHP.

if

Re: Gender icon

Posted: Sat Jan 30, 2010 10:23 am
by riiel
i made this and both genres have now female icon

Code: Select all

<?php
$icon1="<img src='/gfx/ico/user_mature.png' /> ";
$icon2="<img src='/gfx/ico/user_female.png' /> ";
 
if ($users->getCurGender == 1 && $users->getCurGender == 2)
    echo $icon1;
else
    echo $icon2;
?>

Re: Gender icon

Posted: Sat Jan 30, 2010 10:29 am
by AbraCadaver
riiel wrote:i made this and both genres have now female icon

Code: Select all

<?php
$icon1="<img src='/gfx/ico/user_mature.png' /> ";
$icon2="<img src='/gfx/ico/user_female.png' /> ";
 
if ($users->getCurGender == 1 && $users->getCurGender == 2)
    echo $icon1;
else
    echo $icon2;
?>
So if they are a male AND a female display the male icon? If they are not a male AND a female then display the female icon?

Re: Gender icon

Posted: Sat Jan 30, 2010 10:45 am
by riiel
if they are a male then display the female icon, If they are female then display the female icon.

Re: Gender icon

Posted: Sat Jan 30, 2010 11:04 am
by AbraCadaver
riiel wrote:if they are a male then display the female icon, If they are female then display the female icon.
That's not what your IF statement says.

Re: Gender icon

Posted: Sat Jan 30, 2010 11:07 am
by riiel
But what i must to do ?

Re: Gender icon

Posted: Sat Jan 30, 2010 11:20 am
by AbraCadaver
riiel wrote:But what i must to do ?
As tasairis said, this is very basic PHP. Are you interested in learning PHP or do you just want us to solve this one problem?

Re: Gender icon

Posted: Sat Jan 30, 2010 11:33 am
by riiel
I'm interested, i have homepage and i want explicate this ;)

Re: Gender icon

Posted: Sat Jan 30, 2010 12:08 pm
by AbraCadaver
riiel wrote:I'm interested, i have homepage and i want explicate this ;)

Code: Select all

// this says, IF gender is 1 AND gender is 2 then echo $icon1
// gender will never be equal to 1 AND 2 at the same time will it?
if ($users->getCurGender == 1 && $users->getCurGender == 2)
    echo $icon1;
 
// this says, IF the above condition is not true then echo $icon2
// the above condition will never be true will it?
else
    echo $icon2;

Re: Gender icon

Posted: Sat Jan 30, 2010 1:14 pm
by riiel
I made this but it display only female icon :S

Code: Select all

<? 
($users->getCurGender == 1)?$sexicon="<img src='/gfx/ico/user_mature.png' /> ":$sexicon="<img src='/gfx/ico/user_female.png' /> ";?> 
<?=$sexicon?> <a href="?uID=<?=$users->getCurUid();?>"><b>
              <?=$users->getUsername($users->getCurUid());?></b></a>

Re: Gender icon

Posted: Sat Jan 30, 2010 1:31 pm
by REwing

Code: Select all

if ($users->getCurGender == 1) {
echo $icon1; }
else {
echo $icon2;
}