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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:54:20+00:00 2026-06-10T06:54:20+00:00

Need a big help from you. I need an advice from all you good

  • 0

Need a big help from you.
I need an advice from all you good people out there.

I have some contents that i need to display only to few countries.I am okay with getting the user’s country with Geoip.i am storing my content in MySQL database with a country_code field.country code can be empty or any single code or group of comma separated values

What i want to do is,

  1. checking country_code and if it is empty, display that content for all users.
  2. if country_code is not empty and only a single value,display content only for the given country_code users.
  3. if country_code is group of comma separated values,display contents for all the comma separated country users.

i have two options for do this

  1. adding data columns for each country separately and display contents
    as for example three columns for three countries US,UK,AU and if user’s location is US,

    $sql=mysql_fetch_array(mysql_query("SELECT * FROM content_table WHERE US=='$country_code'"));

  2. adding country data for single column as country_code and store US,UK,AU and if user’s location is US,

    $sql=mysql_fetch_array(mysql_query("SELECT * FROM content_table WHERE country_code!=''"));
    $pieces = explode(",", $sql['country_code']);
    foreach($pieces as $val){
    if($country_code=="US")
    //display content
    }

NOTE:amount of countries may differs according to my needs

what will be the best practice to overcome this,

  • using different columns to different country make fast search but adding more columns is not good i think
  • using single column and iterate comma separated values needs more computation

What should i do..??
please advice me on this.. OR do you have any idea better than this..? Thanks

  • 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-06-10T06:54:22+00:00Added an answer on June 10, 2026 at 6:54 am
    $sql=mysql_fetch_array(mysql_query("SELECT * 
        FROM content_table 
        WHERE country_code = '' 
        OR country_code REGEXP ',?". $user_country_code .",?'"));
    

    If I understood you well, you want to show elements to the user only if the user country code is in the country_code field or if the country_code is not specified ?

    This should do it, even if a database solution would be better.

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

Sidebar

Related Questions

Hey there, I need some help with some MYSQL Joins that I really don't
I need some conceptual help: I am trying to display a page that contains
i have a big solution containing that much projects..i need to find a specific
I have this big function (1300+ lines of code) that takes data from the
I need a serious help from you guys. I need to read the contents
I have a few questions so please bear with me. I need some help
I need to get some stuff sorted out about all this async stuff. Let's
I need some help with a script I am developing. I have some advertisements.
I need big help from you,I want to upload image using amazon s3 web
I made a big oops, and could use some help undoing it. We have

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.