From: Chad B. <ch...@be...> - 2003-05-28 16:35:21
|
I'm looking for any comments you might have on the following: I've been toying around with the idea of grabbing choices for questions from other db tables rather than having to type them into the create survey interface. I believe someone else came up with the idea but after searching the message archive I can't quite track who... Anyway, the idea goes something like this... When creating a new question rather than listing choices that may just be duplication of another table in your database enter a sql query and have phpESP do the work for you. example: let's say you want to list all of the dental clinics for a respondent to choose from. The question text would be: Choose the clinic where you performed the procedures. Question Type could be any type with multiple choices: [Radio, Check Boxes, Drop Down, Rate] Now instead of typing all of the clinics and possibly creating errors along the way. Enter the following special tag and sql. On line 1: <sql>select name from clinic order by name</sql> ( if the clinic table wasn't in the phpESP db then enter an optional argument telling the db name, DB::connect() syntax ) like this: On line 1: <connect> mysql://user:password@machine_address/db_name</connect> On line 2: <sql>select clinic_name from clinic order by clinic_name</sql> Now, when you clicked [New Field] or [Continue] then the choices would be created for you! Implementation: It looks like survey_update() is the only function involved. So, my idea is to trap multiple choice questions that have the <sql> tags and create the choices automagically. Any comments? chad. |