Advertisement

08.05.2008 at 04:17AM PDT, ID: 23621767 | Points: 500
[x]
Attachment Details

Creating an online Survey - Populating form dynamically with radio buttons from mySQL table

Asked by djnsh in Adobe Flex, PHP and Databases

Tags: ,

I am trying(!!) to embrace Flex technology and have recently started using Flex Builder. I have been using PHP and simple HTML forms to generate online surveys for years. However I want to use Flex for my interface where the user selects choices for the survey as I feel it looks modern and professional.

However I am having problems getting my PHP functions to interact correctly with the Flex interface.

I have a survey in a mySQL database. It is divided so that each survey has an ID. The user chooses what they want to complete then according to what was chosen, the relevant list of questions and possible answers each identified by ID's are called from a mySQL database. This is all put together in php.

However the key step which is not working is the display of the question, transmission of the option picked by the user and calling up the next question into Flex until the survey is complete. The option chosen is stored back in the mySQL database using the users IP address as unique identifier. I have used ajax in the past for this where by the user clicks their choice and immediately the next question is called up.

Some of the code is below which is the key step in this process - I have removed some of the SQL queries to simplify matters.

It is basically the section in the brackets after 'do' where the answers to a question are presented which I need to alter.

Really appreciate any help with this as love Flex and Flex Builder.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
if(checkSurvey($_GET['ID']))
	{
		$getQuestions = mysql_query("");
 
		if(mysql_num_rows($getQuestions)>0)
		{
			$row_questions = mysql_fetch_assoc($getQuestions);
			echo $row_questions['survey_question']. '<br /><hr />';
 
$getOptions = mysql_query("SELECT * FROM survey_options WHERE ID_question = '".mysql_real_escape_string($row_questions['ID'])."' ORDER BY ID ASC") or die(mysql_error());
 
$row_options = mysql_fetch_assoc($getOptions);
 
			do {
 
				echo '<br /><input type="radio" name="answer" id="'.$row_options['ID'].'" value="'.$row_options['ID'].'" onClick="ajax_insert_answer(\''.$row_options['ID'].'\', \''.$_GET['ID'].'\', \''.$row_questions['ID'].'\');" /><label for="'.$row_options['ID'].'">'.stripslashes($row_options['poll_option']).'</label>';
 
			} while ($row_options = mysql_fetch_assoc($getOptions));
		}
		else {
			echo 'Survey complete';
		}
	}
[+][-]08.06.2008 at 12:24AM PDT, ID: 22167798

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.09.2008 at 01:09PM PDT, ID: 22197525

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628