Jump to content

Archived

This topic is now archived and is closed to further replies.

radar

need some php magic

Recommended Posts

Okay I have a table in my database called config...  this table has 2 cells.. one called config_name and the other config_value...

Well I need to be able to write to this via a form... The only thing thats ever going to change is config_value -- so how do I take the contents of the form and put it into the database?

Only way i could think of would be to do every query individually.. which would suck...  then i thought someone here might now a bit about doing something like this.. so let me know.. and thanks in advance...

Share this post


Link to post
Share on other sites
Will there be multiple config_name and config_value entries or just one that you change the value you of from time to time?

Share this post


Link to post
Share on other sites
I guess that would have been a good thing to include...  there will be multiple entries.. and here is a sample take on it..

config_name    config_value
domainname    www.mysiste.com
site_name        My Web Site
site_descrip      the elitest of the elite
site_enable      1
req_act            0
req_vis_act      1

It is in that type of setup... goes on an on  holds all the important configuration of my site in this table....

Share this post


Link to post
Share on other sites
I'd use an ini file format

config.php[code]
domainname=www.mysiste.com
site_name=My Web Site
site_descrip=the elitest of the elite
site_enable=1
req_act=0
req_vis_act=1 [/code]

To read it

[code]$config = parse_ini_file('config.php', false);[/code]

$config now is an array

[code]Array
(
    [domainname] => www.mysiste.com
    [site_name] => My Web Site
    [site_descrip] => the elitest of the elite
    [site_enable] => 1
    [req_act] => 0
    [req_vis_act] => 1
)
[/code]

echo $config['site_name']  --> 'My Web Site' ;

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.