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 85993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:10:35+00:00 2026-05-10T22:10:35+00:00

Dup of Some Basic PHP Questions Hello, I have a heap of tinyint fields

  • 0

Dup of Some Basic PHP Questions

Hello,

I have a heap of tinyint fields in a mysql database I need to show with PHP. At the moment I am doing something like this:

if ($row['PAYPAL_ACCEPT'] == '1'){  $paypal = 'Yes';  else  $paypal = 'No';  } 

For each field, which is tedious and seems like there should be a better way, than using an if clause for each field. If there is, what is it?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-10T22:10:35+00:00Added an answer on May 10, 2026 at 10:10 pm

    Building on what’s already been suggested:

    // $columns = string array of column names // $columns = array('PAYPAL_ACCEPT' ... ); foreach($columns as $column) {   $$column = $row[$column] ? 'YES' : 'NO'; } 

    then you can access variables using the column names as variable names:

    print $PAYPAL_ACCEPT; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a database: database with a table: table and some fields: id fname
I have 3 tables and need to select some recoreds, In 2 table of
This is probably not a dup; I have read through many similar problems on
Sorry if this is a dup; I haven't found any questions that pose quite
I have a SQL question that I could use some help with. Still somewhat
I am working with a database that has some duplicate data and am trying
I'm trying to figure out the cleanest way to perform some lookups. I have
Concatenative languages have some very intriguing characteristics, such as being able to compose functions
I need to write a sproc which performs some INSERTs on a table, and
I have a situation where I need to find out the most recent entry

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.