I’m having trouble getting this to work and if anyone can help, it would be greatly appreciated.
I’m trying to establish a global variable of an array of numbers which represent counties an agent works in. These can be obtained by a select statement and will produce one or more rows, each row with only one number. I can then use the “implode” function to change the recordset to a string which I can use in WHERE clauses to list the counties or whatever.
Being new to SC (using SC 7.1 on a Mac) I’m a little stumped about how to code this. I’ve been trying the following and while I don’t get any blank screens or errors, I also don’t create the variable to convert to a string. I’m putting this in the sec_Login app, created in the Security module because there are a number of other global session variables created here. I’ve been trying to write this with a combination of the macros and what PHP I know, but it’s not working.
$sql_area = "SELECT
coid County
FROM
agentarea
WHERE
(uid = ". [uid] .")
ORDER BY
coid";
sc_lookup(rs, $sql_area);
$agent_area = array();
$row_rs = "";
if (count({rs}) !== 0)
{
while ($row_rs = mysql_fetch_assoc({rs}))
{
$agent_area[] = $row_rs[{County}];
}
sc_set_global($agent_area);
}
Again, excuse my ignorance and inexperience. Hopefully one of you old-timers can at least point me in the right direction.