handling vars in prewritten scripts
Moderator: General Moderators
handling vars in prewritten scripts
Ok, let's say I have a script builder, where a manager can build a script for people to read, but he wants variables in it like.... "Thank you for calling $business_name I am $username, How can I help you today?" now those variables have to mean different things depending on who is viewing them, and they are alot more complicated than just getting a username and storing it as a variable. The place has 5 different dba's and multiple scripts for each dba, but they want to define those variables in a management console. What would be the easiest way of going about something like this? My fist though was to build a file called definitions.php and include it in the page depending on what dba they log in to, but upgrading that seems to be a little difficult. I hope I am explaining this correctly, it seems to be a big problem to me, but I am sure someone has faced this before elsewhere. One specific example is if someone logs in as part of one dba the variable $product has to be "Google", but if they log in as a different dba the same variable $product has to be "Bing". For some reason I can't wrap my head around this. Thank you in advance for any help.
Re: handling vars in prewritten scripts
If I'm understanding it correctly then the optimal solution would be a database table.
In the user table for the dbas add each account with a field of "class", e.g. Dba1, power user, googleman, bingman.
Create another table which acociates a class with a series of variable names
ID, keyName, value, className
1, productName, Google, googleman
Then, when they login, scan the table for all className=xyz and use keyName and value to correctly populate the variables.
At least this way it's a db managed section and doesn't require code updates to make changes.
That is if I've understood your problem.
In the user table for the dbas add each account with a field of "class", e.g. Dba1, power user, googleman, bingman.
Create another table which acociates a class with a series of variable names
ID, keyName, value, className
1, productName, Google, googleman
Then, when they login, scan the table for all className=xyz and use keyName and value to correctly populate the variables.
At least this way it's a db managed section and doesn't require code updates to make changes.
That is if I've understood your problem.
Re: handling vars in prewritten scripts
that's exactly what I was talking about, I had thought about a db storage method but after programming all of what I am doing right now for some reason my brain couldn't wrap itself around getting those vars back out as the appropriate var names, but that works perfectly. Thank you.