Gender icon

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
riiel
Forum Newbie
Posts: 16
Joined: Sat Apr 25, 2009 3:29 am

Gender icon

Post 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 ? :)
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Gender icon

Post by requinix »

This is really basic PHP.

if
riiel
Forum Newbie
Posts: 16
Joined: Sat Apr 25, 2009 3:29 am

Re: Gender icon

Post 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;
?>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Gender icon

Post 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?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
riiel
Forum Newbie
Posts: 16
Joined: Sat Apr 25, 2009 3:29 am

Re: Gender icon

Post by riiel »

if they are a male then display the female icon, If they are female then display the female icon.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Gender icon

Post 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.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
riiel
Forum Newbie
Posts: 16
Joined: Sat Apr 25, 2009 3:29 am

Re: Gender icon

Post by riiel »

But what i must to do ?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Gender icon

Post 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?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
riiel
Forum Newbie
Posts: 16
Joined: Sat Apr 25, 2009 3:29 am

Re: Gender icon

Post by riiel »

I'm interested, i have homepage and i want explicate this ;)
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Gender icon

Post 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;
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
riiel
Forum Newbie
Posts: 16
Joined: Sat Apr 25, 2009 3:29 am

Re: Gender icon

Post 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>
REwing
Forum Newbie
Posts: 2
Joined: Sat Jan 30, 2010 1:06 pm

Re: Gender icon

Post by REwing »

Code: Select all

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