Forum Moderators: coopster
I have a website where I have surveys up, and whenever I need to add a new survey I need to edit my php code in my webspace. I.E. For the front end of the site, since the survey's are always a little different, I need different ways of outputting the information. There are many other small places where I need to make little changes as well.
I might be able to streamline this process a little more if I had a way of inputting on the browser the information and type for each question so it could automatically make some php code to output those survey results correctly.
Is there some way I can do this without an extra program? Could I use one php file to edit another? I don't know where the limits are.
Thanks a bunch
if ($config['showreset']==true) $survey.="<input typ... You can put in strings of text, or URLs to images as well.
Head up the file with a list of simple configuration statements and notes:
$config['title']="Great Survey"; // main title (Text)
$config['showreset']=false; // true/false - show the reset button? That way you just change the configuration variable settings, and the script changes its behaviour. Do not worry about a few extra clauses which don't get run, the overhead is nothing. Unless you have one of the worlds biggest websites of course.
If you want to progress that idea further, you can make one PHP script which writes the set of configuration values in response to you filling in a form; typically they will be written to a file named config.php which is referenced by include('config.php'); in the main script.
Another option is to use a database to store the various sets of configuration; in that way you just need config to tell each survey what it's database ID is - it can do a quick SELECT and fetch the set of configuration. This has the advantage of central administration of all surveys and eliminating the need to edit PHP just to change a setting.
For design details; use CSS. Don't use inline styles, but instead control them from your external stylesheet. This is another way to avoid editing PHP.