This topic is locked

Misc variables page

3/1/2015 10:06:43 PM
PHPRunner General questions
S
Stucco author

Hi,
I'm wondering if anyone else has come across the need and a possible solution for a 'Miscellaneous settings page'. This would look like a series of name value pairs, where each pair was content-type restricted.
Here is an example: There is a list of options controlled via lookup table. I do not control the list. There is a need to have a default option picked for new records. But I cannot set a default because the list of options is not fixed at build time. How can I give control to set a default in the database, which I can read and set when a record is created?
But that is just one example setting, whereas there are actually many like this.
Another is "this is your customizable header welcome message", which would be a text field instead of the lookup table in the previous example.
Does anyone have a solution for this type of thing?
Thanks!

Sergey Kornilov admin 3/4/2015

You are going to need an extra table to store those name-value pairs i.e.

ID Name Value

-----------------------------------------

1 defLookupName Some default value

2 msgWelcome Hello citizen!


Then in your code you can read the corresponding value from this table and do something useful with it.

$msg = DBLookup("select Value from tblNameValue where Name='msgWelcome'");

echo $msg;