Global query

I’m using a settings table to define some colors for the site which are used to show status of certain cells and rows
These colors are applied accross the entire site

Can I just add these to All Pages > Global code ?

$CellRed = ExecuteScalar(“SELECT Settings.Value FROM Settings WHERE Settings.Setting=‘CellRed’”);
$CellOrange = ExecuteScalar(“SELECT Settings.Value FROM Settings WHERE Settings.Setting=‘CellOrange’”);
$CellGreen = ExecuteScalar(“SELECT Settings.Value FROM Settings WHERE Settings.Setting=‘CellGreen’”);
$RowRed = ExecuteScalar(“SELECT Settings.Value FROM Settings WHERE Settings.Setting=‘RowRed’”);
$RowOrange = ExecuteScalar(“SELECT Settings.Value FROM Settings WHERE Settings.Setting=‘RowOrange’”);
$RowGreen = ExecuteScalar(“SELECT Settings.Value FROM Settings WHERE Settings.Setting=‘RowGreen’”);

I get undefined variable using this method.
where/how can i use these queries globally?

Assume you are calling those global variables from “Row_Rendered” server event, then you need to declare those variables inside this event by using “global” keyword, for example:

global $CellRed;
global $CellOrange;
// … and so forth

then after those lines, you may use those global variables as usual in that same event, too.

Right… thanks!
I keep forgetting to call them in Row_Rendered
Doh!