Jump to content


Photo

need some php magic


  • Please log in to reply
3 replies to this topic

#1 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 30 August 2006 - 12:20 AM

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...

#2 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 30 August 2006 - 12:30 AM

Will there be multiple config_name and config_value entries or just one that you change the value you of from time to time?

#3 radar

radar
  • Members
  • PipPipPip
  • Advanced Member
  • 645 posts
  • LocationSLC

Posted 30 August 2006 - 02:55 AM

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....

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,020 posts

Posted 30 August 2006 - 06:53 AM

I'd use an ini file format

config.php
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

To read it

$config = parse_ini_file('config.php', false);

$config now is an array

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
)

echo $config['site_name']  --> 'My Web Site' ;
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users