Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6251261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:34:54+00:00 2026-05-24T13:34:54+00:00

I have user table having fields gender and first name like this.. The value

  • 0

I have user table having fields gender and first name like this.. The value stored in the database for gender type is 0 for M(Male) and 1 for F(Female).
I am retrieving the details from database.

By using the following query and displaying the details in table using below code:

My problem is how do I display the ‘M’ in gender type column if the value is coming from user table for gender is ‘0’.
And same for Female is I want to display the ‘F’ if the gender type column if the value is coming from user table for gender is ‘1’.

Can anyone help on this one?

      modified code :


               GOT an error :Parse error: syntax error, unexpected $end 


               <?php
              $rows=array();
            $query = "SELECT CONCAT(usrFirstname,'',usrSurname) As FullName,usrNickname AS    Nickname,";
            $query.= "usrEmail As EmailAddress,usrGender AS Gender,DATE_FORMAT(usrDOB,'%d%m%y') As DOB,usrBelt AS BeltId";
   $query.= " FROM user";
   $result = mysql_query($query);
 echo mysql_error();
      if($result)
       {
        while($row=mysql_fetch_assoc($result))
  {
       $rows[] = $row;
     }
   }
      <?php 
       if ($row['Gender'] == '0'){
        $Gender = 'M';
           } else {
         $Gender = 'F';

        ?>

     <link href="../../css/styles.css" rel="stylesheet" type="text/css" />
      <div class="subheader" style="margin:16px 0 0;width:980px font-style:bold"><div        class="subheaderl"></div><div class="subheaderr"></div>Users registered at your     facility</div>
       <div class="div" style="overflow-y:scroll;height:500px">
          <table name="t" id ="t" height= "140" width="800">





     <tr style="text-align:left; line-height=10px; word-spacing:0px">
         <thead style="font-weight:bold; font-size:12px;">  
          <th>Full Name</th>
          <th>NickName</th>
             <th>Email Address</th>
              <th>Gender</th>
           <th>DOB</th>
             <th>Belt ID</th>      
       </thead>  
         <?php foreach ($rows as $row){?>
            <tr style="font-size:small">
               <td><?php echo $row['FullName']?></td>
              <td><?php echo $row['Nickname']?></td>
    <td><?php echo $row['EmailAddress']?></td>
    <td><?php echo $Gender?></td>       
    <td><?php echo $row['DOB']?></td>
    <td><?php echo $row['BeltId']?></td>
  </tr>
 <?php }?>

would any one help on this

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:34:56+00:00Added an answer on May 24, 2026 at 1:34 pm

    SELECT CONCAT(usrFirstname,'',usrSurname) As FullName,
    usrNickname AS Nickname,
    usrEmail As EmailAddress,
    CASE WHEN usrGender = 0
    THEN
    'M'
    ELSE
    'F'
    END AS Gender,
    DATE_FORMAT(usrDOB,'%d%m%y') As DOB,usrBelt AS BeltId
    FROM user

    if you put this in the query it return M or F

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table structured like this (irrelevant fields omitted for brevity): rankings
I have a user table 'users' that has fields like: id first_name last_name ...
I have a user table in my mysql database that has a password column.
I have a user-defined table type. I want to check it's existence before editing
I have a data table having fields( date , company , data_id , rank
We have a user table, every user has an unique email and username. We
I have a User table that has all of their avatars saved in an
I have a User table which has a PrivilegeId foreign key points to a
Consider i have a user table and I have three columns mobilePhone , homePhone
In my Ruby on Rails app, I have a User table and a Foo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.