Jump to content


Photo

Not defining gender, from DB


  • Please log in to reply
4 replies to this topic

#1 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 08 September 2006 - 05:45 PM

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.
<?
if($rowuser["genderid"]%2==0)
echo Female;
   else
echo Male;
?>



#2 robos99

robos99
  • Members
  • PipPipPip
  • Advanced Member
  • 55 posts

Posted 08 September 2006 - 06:11 PM

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?

#3 mewhocorrupts

mewhocorrupts
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts
  • LocationParker, CO

Posted 08 September 2006 - 06:53 PM

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.

<?
if($rowuser["genderid"]%2==0)
echo Female;
   else
echo Male;
?>


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.
-mewhocorrupts

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 08 September 2006 - 10:20 PM

Use an array
<?php
$gender = array (
    1 =>  'Male',
    2 =>  'Female',
    3 =>  'Couple',
    4 =>  'Group',
    5 =>  'Couple FF',
    6 =>  'Couple MM'
);
echo $gender[$rowuser["genderid"]];
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 Gregg

Gregg
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts
  • LocationUSA

Posted 08 September 2006 - 11:23 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users