note 71130 deleted from language.variables.variable by philip
| From: | philip@php.net | Date: | Sun, 28 Jan 2007 17:48:36 +0000 |
| Subject: | note 71130 deleted from language.variables.variable by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-122294@lists.php.net to get a copy of this message | ||
Note Submitter: nandcc at gmail dot com
----
If you have certain settings that you would like to have run throughout your site and be changeable
on the fly, then you set them by having two things:
1. A table in your db that has certain values:
1. optionValue - the value of the variable that you want to have throughout your site
2. optionName - the name of the variable you are using
2. The following script in your globals or includes file:
<?PHP
$query = "SELECT optionValue, optionName FROM siteOptions";
$result = mysql_query($query);
while($res = mysql_fetch_array($result,MYSQL_ASSOC)){
// $_SESSION[$res['optionName']] = $res['optionValue'];
$a = $res['optionName'];
$$a = $res['optionValue'];
}
mysql_free_result($result);
?>
This script will go in and dynamically create, name, and value variables from the database. You can
use this instead of the session variables. When you change a setting in your admin settings form or
in the table of your database then it will automatically have the new value on the next page load.
No waiting, and no reuploading of the script just to change one variable.