This topic is locked
[SOLVED]

 Best method for Default Value from Table

8/9/2013 4:07:36 PM
PHPRunner General questions
N
nti author

Hey, I wish to get some feedback... please.
I wish to utilize data from a "settings" table.
I am sure there is a better way to do this ? than my method below ?

  1. Visual Editor Field setting, Default Value: $_SESSION["My_Default"]



  2. Events Page, Add page, Add page: Before process



$conn=db_connect();

global $dal;

$dal_table = $dal->Table("My_Settings_Table");

$rstmp = $dal_table->QueryAll();

$datatmp = db_fetch_array($rstmp);

$_SESSION["My_Default"] = $datatmp["My_Settings_Table_Field"];


Thank you.

C
cgphp 8/10/2013

In the "Process record values" event of the add/edit pages, enter this code:

$rs = CustomQuery("SELECT My_Settings_Table_Field FROM My_Settings_Table");

$record = db_fetch_array($rs);

$values['field_to_be_prefilled'] = $record['My_Settings_Table_Field'];


Replace field_to_be_prefilled with the real name of the field you want to prefill.

N
nti author 8/12/2013

Thank you Cristian, Works great.