Jump to content

Not defining gender, from DB


Gregg

Recommended Posts

Ok, the feild i am trying to pull the info from has serveral values.
It's on my results page, and it shows all the users matching there discription..
(0)
(1) Male
(2) Female
(3) Couple
(4) Group
(5) Couple FF
(6) Couple MM

And i can get it to work using this but it wont pull all the values.
[code]<?
if($rowuser["genderid"]%2==0)
echo Female;
  else
echo Male;
?>[/code]

Link to comment
https://forums.phpfreaks.com/topic/20145-not-defining-gender-from-db/
Share on other sites

[quote author=Gregg link=topic=107375.msg430767#msg430767 date=1157737546]
Ok, the feild i am trying to pull the info from has serveral values.
It's on my results page, and it shows all the users matching there discription..
(0)
(1) Male
(2) Female
(3) Couple
(4) Group
(5) Couple FF
(6) Couple MM

And i can get it to work using this but it wont pull all the values.
[code]<?
if($rowuser["genderid"]%2==0)
echo Female;
   else
echo Male;
?>[/code]
[/quote]

I'm a little confused by the code you included in your post.  Why would you use the modulus operator to determine if they are male or female?  What if the "genderid" is "5" -- Couple FF -- the code you have would print Male.
Use an array
[code]<?php
$gender = array (
    1 =>  'Male',
    2 =>  'Female',
    3 =>  'Couple',
    4 =>  'Group',
    5 =>  'Couple FF',
    6 =>  'Couple MM'
);
echo $gender[$rowuser["genderid"]];
?>[/code]
Thanks "Barand" worked great!
And sorry i posted this kind of confusing i was on the way out so needed to save it befor i left lol..
I needed the right code to get all of the genders and the one posted worked when i inter graded it into the head code so thanks.

:D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.