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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:08:18+00:00 2026-05-31T08:08:18+00:00

Finally completed the frontend of my website, I am now looking at coding the

  • 0

Finally completed the frontend of my website, I am now looking at coding the backend which needs an overhaul, the coding is very messy and uses far too many SQL Connections and commands, so much so that the host is complaining about it.

One of the main problems I am having is the Site Settings page, problem is this page will soon contain over 10 different options, and I prefer not to have a MySQL Update simply updating the option field to what it already is, so I am wondering if anyone has any ideas?

This is the structure of my options table, nice and simple which I recently changed from an awful layout.

Table structure for options

What would be the best way to edit these options without having to update every single one, and what would be the best way to have them in a function? Currently, the function I have was made back when I was new to coding, and you can see that is is very uneffective(note it uses the old table structure)

function site_upd($site_title, $site_email, $maint_status, $maint_mess, $upload_disable, $site_url, $reg_status, $land_mess)
{
    if( !$site_title ) 
    {       
        echo $this->errorMessage('There was no <b>site title</b> supplied, therefore we can not continue with this request.', 'error');
    } 

    else 
    {
        $this->logQuery('Updated site settings');
        $query = "UPDATE `table`.`settings` SET `site_title` = '".$site_title."', `site_email` = '".$site_email."', `maint_status` = '".$maint_status."', `maint_mess` = '".$maint_mess."', `upload_disable` = '".$upload_disable."', `site_url` = '".$site_url."', `registration_status` = '".$reg_status."', `landing_mess` = '".$land_mess."' WHERE `settings`.`sid` = '1'";
        mysql_query($query) or die(''.mysql_error()); } }

So yeah, there is the awful old structure and my old way of doing things, before I get stuck into coding I want other peoples opinions on what is the best way to do 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-31T08:08:20+00:00Added an answer on May 31, 2026 at 8:08 am

    You can work with $_POST Variable to simplify the update method.

    This is what I usually do:

    First I create a non specific function to update:

    function update_db($table, $id,$idvalue,$field,$fieldvalue){
       return mysql_query("update ".$table." set ".$field."=".$fieldvalue." where ".$id."=".$idvalue);
    }
    

    Then i create the specific function to the table (config i.e):

    function update_table_config($name,$value){
       return update_db("config","name",$id,"value",$value);
    }
    

    In the form i call all <input> like its name on the table:

    Site Name: <input type="text" name="site_name">
    ...
    

    and in the “action” page i check $_POST array:

    $data_array=$_POST;
    
    if(check_variables($data_array)){
        foreach ($data_array as $key=>$value){
            update_table_config($key,$value);
        }
    }
    

    the function check_variables has all the checks that you need for all the fields:

    function check_variables($data){
         if($data["site_title"]=="") return false;
         if(!is_numeric($data["landing_mess"])) return false;
         ...
         return true;
    }
    

    with this methods if in the future you have to include more fields in the configuration table you only have to add the <input> field and a check in check_variables function if needed

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

Sidebar

Related Questions

UPDATE: It Is Now Working I was able to finally get it completed. A
I've finally completed a working version of my first ever CSS-supported site (thanks to
I finally let windows nag me into upgrading from IE6 to 8. Now in
I'm finally getting my team to embrace source code management now that we're working
Finally having completed an application, I am about to profile time taken to run
I'm trying to write very simple program which will imitate simple DeadLock, where Thread
I finally got my group to switch from SourceSafe to Subversion. Unfortunately, my manager
I finally have a hardware guy that is insterested in controlling the firmware. This
I finally found out the difference between UTC and GMT by making the effort
I finally have my C++ Builder 2010 installation the way I want it, with

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.