Jump to content

Archived

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

Gregg

Not defining gender, from DB

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]

Share this post


Link to post
Share on other sites
What exactly is the problem you're having?

Your list of values...are those just the possible values for your gender column in the DB? Or is that entire list in the gender column?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

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.