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

  • Home
  • SEARCH
  • 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 6654805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:26:01+00:00 2026-05-26T01:26:01+00:00

My table is setup like this: id | config_name | config_value 1 | language

  • 0

My table is setup like this:

id | config_name | config_value

1 | language | English
2 | currency | $
3 | date_format | M d, Y
etc…

I’m trying to query the database to use this information as needed throughout a page. There may be 100 rows in this table, but I only need to use specific ones on a page. That’s why I need to specify which one(s) I’m using. For example:

$config->language; would echo “English”
$config->currency; would echo “$”, etc.

How would I set this up?

I know how to get the values and echo the same thing over and over again in a while loop:

$systemconfig = mysql_query("SELECT config_name, config_value FROM system_config");             

    while($configs = mysql_fetch_array( $systemconfig )) {
        echo "The value of ".$configs['config_name']."is: ".$configs['config_value'];

    } // end while

… but I don’t want to be stuck in that loop as it cycles through all the configs in the database. That’s why I would like to be able to echo the specific config values I specify throughout the page like mentioned above, ie: $config->language

Could someone enlighten me?

  • 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-26T01:26:02+00:00Added an answer on May 26, 2026 at 1:26 am

    Well this is pretty straight forward, you have to walk yourself through the thought process:

    • Create an object with a constructor that connects and grabs config info
    • Have call the object when needed.

    Here is a rough object example (you fill in the code needed):

    <?php
    class config
    {
        protected $self = array();
    
        function __construct()  // a constructor runs on initialization of object
        {
           $q = mysql_query("SELECT config_name, config_value FROM system_config");             
    
            while($configs = mysql_fetch_array( $q )) {
                $this->add($configs['config_name'], $configs['config_value']);
    
            }
        }
    
        function add($key, $value){
            $this->self[$key] = $value;
        }
    
        function __get( $name = null ) {   // this is a getter that you call
            if(isset($this->self[$name])){ 
                return $this->self[$name];
            } 
            return false;  // this is returned if element doesn't exist
        }
    }
    
    $config = new config;
    echo $config->language;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a css table setup like this: <div class='table'> <div> <span>name</span> <span>details</span> </div>
I have a table setup like this (simplified for example): user_id item_id click_dt Each
I have a table named sessions setup like this: ################################# # set # timestamp
I have a table setup like this: <table> <thead> <th> <input type=checkbox class=check-all />
Database setup (MySQL) table: top_fives id, uid, first, second, third, fourth, fifth, creation_date 1,
Setup: Contact database using 4 tables Contacts Cities States Zips Structure: CREATE TABLE `contacts`
I'm implementing a table with a fixed header using this kind of setup: <div
I have a data tables with this type of setup. Table A AID AName
I've got a table setup like so: [ReferredID], [Name] 1, Irwin 2, Marc 1,
I've got a database that looks like this: ID Name ParentID 1 1 0

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.