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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:42:44+00:00 2026-05-20T04:42:44+00:00

I have a simple php web app. I need to add an option for

  • 0

I have a simple php web app. I need to add an option for users to hide certain details from their public profiles. The database is something like:

id     username    phone      email 
1      foo1        888-888    a1@b.com
2      foo2        999-999    a2@b.com
3      foo3        111-111    a3@b.com

Now I have 2 options. First is to have another table and use id as the foreign key for referencing. Like

fkeyID     disp_phone      disp_email 
1          0               0
2          0               1
3          1               1

Where 1 is true and 0 is false. Then use SQL join on 2 tables to find whether they want to display their phone/email or not.

2nd Option is: to prefix some flag value like $ in case user wants to forbid public view. Then use a simple php check before displaying or saving preferences. Like:

id     username    phone      email 
1      foo1        $888-888   $a1@b.com
2      foo2        $999-999   a2@b.com
3      foo3        111-111    a3@b.com

Please tell which is the better option in terms of space and complexity and why.

  • 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-20T04:42:45+00:00Added an answer on May 20, 2026 at 4:42 am

    Given that id and fKeyID are both primary keys an SQL JOIN will be very efficient in the first solution.

    IMO the first solution is superior to the second since you can perform SELECT s based on visibility settings in an efficient way (i.e., select only users whose phone numbers are public without considering substrings, e.g., ... WHERE LEFT(phone, 1) != '$' etc.).

    (This advantage may have no relevance in your case, however.)


    And then there was this third possibility:

    id | username | phone   | phone_disp | email    | email_disp
    ------------------------------------------------------------
    1  | foo1     | 888-888 | 0          | a1@b.com | 0
    2  | foo2     | 999-999 | 0          | a2@b.com | 1
    3  | foo3     | 111-111 | 1          | a3@b.com | 1
    

    This will keep data and visibility settings together. It is otherwise identical to the first solution, except you don’t need to JOIN.

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

Sidebar

Related Questions

I'm building a simple PHP web app that uses Paypal to add credit to
At work we have a web app that we'll need to interface with another
Say I want to have a simple web app that takes some user input,
I've written a simple issue tracker for my web app. I have some comments
I have a simple php script on a server that's using fsockopen to connect
I have this simple php script <?php echo '<pre>'; // Outputs all the result
I am pretty new to php, but I am learning! I have a simple
I have some code I've written in PHP for consuming our simple webservice, which
Ok this is more of general technology/approach question. We have a very simple web
I need your advice. We have an already working web resource management application, we

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.