note 71130 added to language.variables.variable
| From: | nandcc at gmail dot com | Date: | Mon, 13 Nov 2006 14:31:38 +0000 |
| Subject: | note 71130 added to language.variables.variable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119665@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 64.71.164.2
Probable Submitter: 216.106.46.193
----
Manual Page -- http://www.php.net/manual/en/language.variables.variable.php
Edit -- https://master.php.net/note/edit/71130
Del: integrated -- https://master.php.net/note/delete/71130/integrated
Del: useless -- https://master.php.net/note/delete/71130/useless
Del: bad code -- https://master.php.net/note/delete/71130/bad+code
Del: spam -- https://master.php.net/note/delete/71130/spam
Del: non-english -- https://master.php.net/note/delete/71130/non-english
Del: in docs -- https://master.php.net/note/delete/71130/in+docs
Del: other reasons-- https://master.php.net/note/delete/71130
Reject -- https://master.php.net/note/reject/71130
Search -- https://master.php.net/manage/user-notes.php