Help tabulating survey data
Now that I have my survey working, I need to add up the data and show it back to the user. This is the code I have right now for the first question. I have to do this for about 15 multiple choice questions and something similar for short answer questions. How can I create a function to do most of the work? Or am I in over my head??
<?php
$surveyinfo = mysql_query(\"SELECT * FROM survey_quickquizW07\") or die (\"Database Error\");
// function to calculate the percent
function getPercent ($value, $total) {
$percent = $value / $total * 100;
$percent = round ($percent, 0);
return $percent;
}
// show the data
while($row = mysql_fetch_array($surveyinfo))
{
$total ++; // increase the total each time you go through
if ($row['1firstthing'] == \"a\" ){ // calculate the totals for each value
$firstthing_a ++;
}elseif($row['1firstthing'] == \"b\") {
$firstthing_b ++;
}elseif($row['1firstthing'] == \"c\") {
$firstthing_c ++;
}elseif($row['1firstthing'] == \"d\") {
$firstthing_d ++;
}elseif($row['1firstthing'] == \"e\") {
$firstthing_e ++;
}elseif($row['1firstthing'] == \"f\") {
$firstthing_f ++;
}elseif($row['1firstthing'] == \"g\") {
$firstthing_g ++;
}
}
// echo back in a table
echo \"<p> the total is \" . $total . \"</p>\";
echo \"<li>What's the first thing you did after you unpacked? <table><tr><th>answer</th><th>Total Votes</th><th>Percent</th></tr>
<tr><td>Met the Don and other people on my floor</td><td> \" . $firstthing_a . \"</td><td>\" . getPercent($firstthing_a, $total) . \"%</td></tr>
<tr><td>Set up ResNet</td><td>\" . $firstthing_b . \"</td><td>\" . getPercent($firstthing_b, $total) . \"%</td></tr>
<tr><td>Took a nap</td><td>\" . $firstthing_c . \"</td><td>\" . getPercent($firstthing_c, $total) . \"%</td></tr>
<tr><td>Played in the elevator</td><td>\" . $firstthing_d . \"</td><td>\" . getPercent($firstthing_d, $total) . \"%</td></tr>
<tr><td>Checked Facebook</td><td>\" . $firstthing_e . \"</td><td>\" . getPercent($firstthing_e, $total) . \"%</td></tr>
<tr><td>Cried</td><td>\" . $firstthing_f . \"</td><td>\" . getPercent($firstthing_f, $total) . \"%</td></tr>
<tr><td>Other</td><td>\" . $firstthing_g . \"</td><td>\" . getPercent($firstthing_g, $total) . \"%</td></tr>
</table>
</li>\";
echo \"</ol>\"
?>
Here's the link to the quiz: http://www.housing.uwaterloo.ca/surveys/quick-quiz.php
ChadR posted this at 19:42 — 29th March 2007.
They have: 43 posts
Joined: Mar 2007
Well if you setup the form to be pulled from the database then you could setup loops to display the information. I don't know if it will be "time saver" but if you ever had to change options it may save some time. Is that enough information to get you started or do you need more guidance?
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
ChadR posted this at 19:52 — 29th March 2007.
They have: 43 posts
Joined: Mar 2007
After reading another post it appears you are new to PHP/MySQL
I Suggest Making a Table for the Quiz like
CREATE TABLE `options` (
`OptionId` int(11) unsigned NOT NULL auto_increment,
`QuestionId` tinyint(2) unsigned NOT NULL,
`Answer` varchar(255) NOT NULL,
PRIMARY KEY (`OptionId`),
KEY `QuestionId` (`QuestionId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE TABLE `questions` (
`QuestionId` tinyint(2) unsigned NOT NULL auto_increment,
`Question` varchar(255) NOT NULL,
PRIMARY KEY (`QuestionId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 20:06 — 29th March 2007.
She has: 11,421 posts
Joined: Jun 1999
Yes, I'm very new to php and mySQL. I just started working with it in January.
So do you mean putting the questions and answers into the database to start with? That has crossed my mind...
Megan
Connect with us on Facebook!
pr0gr4mm3r posted this at 20:23 — 29th March 2007.
He has: 1,502 posts
Joined: Sep 2006
This seems inefficient:
<?php
if ($row['1firstthing'] == \"a\" ){ // calculate the totals for each value
$firstthing_a ++;
}elseif($row['1firstthing'] == \"b\") {
$firstthing_b ++;
}elseif($row['1firstthing'] == \"c\") {
$firstthing_c ++;
}elseif($row['1firstthing'] == \"d\") {
$firstthing_d ++;
}elseif($row['1firstthing'] == \"e\") {
$firstthing_e ++;
}elseif($row['1firstthing'] == \"f\") {
$firstthing_f ++;
}elseif($row['1firstthing'] == \"g\") {
$firstthing_g ++;
}
?>
This would probably be better:
<?php
$firstthing[$row['1firstthing']]++;
?>
Megan posted this at 20:42 — 29th March 2007.
She has: 11,421 posts
Joined: Jun 1999
That's exactly the part I was trying to make more efficient.
What is the line that you posted doing, exactly? Does that do everything that I had in the first section?
Megan
Connect with us on Facebook!
pr0gr4mm3r posted this at 21:33 — 29th March 2007.
He has: 1,502 posts
Joined: Sep 2006
Your version will leave the $firstthing_x variables with the counts. My version leaves $firstthing['x'] with the counts. It's using an array instead of separate variables.
Megan posted this at 12:50 — 30th March 2007.
She has: 11,421 posts
Joined: Jun 1999
So does anyone have any suggestions on how to put that all into a function so I don't have to rewrite it 15 times? I want to get this done very soon so I might have to do it the long way...
Megan
Connect with us on Facebook!
pr0gr4mm3r posted this at 13:01 — 30th March 2007.
He has: 1,502 posts
Joined: Sep 2006
I could use more information on your table, but here is the general way to do it.
Your going to have to put everything inside your while($row = mysql_fetch_array($surveyinfo)) loop including everything printing the html.
For example:
<?php
echo \"<table>\";
while($row = mysql_fetch_array($surveyinfo))
{
echo \"<tr><td>\" . $row[0] . \"</td><td>\" . $row[2] . \"</td><td>\" . $row[3] . \"</td></tr>\";
}
echo \"</table>\";
?>
The above code takes the first three lines and prints them to a table.
Megan posted this at 13:21 — 30th March 2007.
She has: 11,421 posts
Joined: Jun 1999
Here's what I have now:
<?php
function processData($field) { // $field would be something like $row['1firstthing']
$surveyinfo = mysql_query(\"SELECT $field FROM survey_quickquizW07\") or die (\"Database Error\");
echo \"<p>The field is \" . $field;
while($row = mysql_fetch_array($surveyinfo))
{
$total ++; // increase the total each time you go through
if ($row[$field] == \"a\" ){ // calculate the totals for each value
$value_a ++;
}elseif($row[$field] == \"b\") {
$b ++;
}elseif($row[$field] == \"c\") {
$c ++;
}elseif($row[$field] == \"d\") {
$d ++;
}elseif($row[$field] == \"e\") {
$e ++;
}elseif($row[$field] == \"f\") {
$f ++;
}elseif($row[$field] == \"g\") {
$g ++;
}
}
echo \"<p>The value of a is \" . $value_a . \"</p>\";
return $value_a;
}
?>
This is working to calculate the values, the problem is that I can't seem to get $value_a out of this function to use later on. How do I do that??? I thought that's what return did but it's not.
Thanks for any help.
Megan
Connect with us on Facebook!
pr0gr4mm3r posted this at 13:24 — 30th March 2007.
He has: 1,502 posts
Joined: Sep 2006
How are you calling the function?
ChadR posted this at 13:52 — 30th March 2007.
They have: 43 posts
Joined: Mar 2007
You really should be storing the total value into the database as a solid number. So you would have a table that had totals. This will save you a lot of resources as you will not have to go through all the records to get something as simple as a Total. But if you choose to count all the records each time you can use foreach.
Hopefully that will point you in the right direction. I really think for what you are doing though you should take your Quiz put it into MySQL with the questions and answers as the previous post states. You should also be keeping a the totals in a database instead of making MySQL pull all the records to compute results.
For Example you might add a Selected field to the Options database where each time someone selected that option it would add 1 to the database.
<?php
mysql_query(\"UPDATE options SET Selected = Selected + 1 WHERE OptionId = 1\");
?>
Now all you would have to do is call each of the options
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 15:54 — 30th March 2007.
She has: 11,421 posts
Joined: Jun 1999
Oh, I see! Yes, that would be much better! I wonder if I could get that done in time....
Megan posted this at 17:00 — 30th March 2007.
She has: 11,421 posts
Joined: Jun 1999
So, I'm a little confused about how I'm supposed to set up these tables. I have a table for all the options. Each possible answer has a field. Then I would increment that by 1 every time it would selected. So how does that work when the form is selected? Would each option have to have it's own value in the form?? And at the same time I would have to update the total field for that question, right?
Above you showed me two tables - I'm not sure how that works either. I've only ever done stuff with one table at a time (total noob!). Oh, and I'm using phpMyadmin to do the SQL stuff. I don't know how to type it in like that.
Edit: I'm sort of figuring this out. If I did it this way, how would I store the free text answers? Would that go into another table?
Megan
Connect with us on Facebook!
ChadR posted this at 17:52 — 30th March 2007.
They have: 43 posts
Joined: Mar 2007
Yes use PHPMyAdmin... Click the SQL Tab and Insert the Following
<?php
CREATE DATABASE `quiz` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `quiz`;
-- --------------------------------------------------------
--
-- Table structure for table `options`
--
CREATE TABLE `options` (
`OptionId` int(11) unsigned NOT NULL auto_increment,
`QuestionId` tinyint(2) unsigned NOT NULL,
`Answer` varchar(255) NOT NULL,
`Selected` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`OptionId`),
KEY `QuestionId` (`QuestionId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Dumping data for table `options`
--
INSERT INTO `options` (`OptionId`, `QuestionId`, `Answer`, `Selected`) VALUES
(1, 1, 'Met the Don and other people on my floor', 1),
(2, 1, 'Set up ResNet', 0),
(3, 1, 'Took a nap', 0),
(4, 1, 'Played in the elevator', 0),
(5, 1, 'Checked Facebook', 0),
(6, 1, 'Cried', 0),
(7, 1, 'I didn’t… (unpack)', 0),
(8, 1, 'FillinBlank', 0),
(9, 2, 'Never', 0),
(10, 3, 'Weekly', 0),
(11, 2, 'My mom does it when I go home for the weekend', 0),
(12, 2, 'When I run out of underwear', 0);
-- --------------------------------------------------------
--
-- Table structure for table `questions`
--
CREATE TABLE `questions` (
`QuestionId` tinyint(2) unsigned NOT NULL auto_increment,
`Question` varchar(255) NOT NULL,
PRIMARY KEY (`QuestionId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `questions`
--
INSERT INTO `questions` (`QuestionId`, `Question`) VALUES
(1, 'What''s the first thing you did after you unpacked?'),
(2, 'How often do you do laundry?');
?>
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
ChadR posted this at 17:55 — 30th March 2007.
They have: 43 posts
Joined: Mar 2007
That is the Complete First 2 questions added to the database.
Next I will provide you with the Code to get the Information from the Database to Display in a Browers.
<?php
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
<title>Untitled Document</title>
</head>
<body><form action=\" echo $_SERVER['PHP_SELF']; \" method=\"post\" enctype=\"multipart/form-data\" name=\"Quiz\"><table><tr><td>The Quiz
</td></tr>
// Put the Options in An Array
$query = mysql_query(\"SELECT OptionId, QuestionId, Answer FROM options\");
for ($i = 1; $row = mysql_fetch_assoc($query); $i++)
{
$Options[$i][0] = $row['OptionId'];
$Options[$i][1] = $row['Answer'];
$Options[$i][2] = $row['QuestionId'];
$Options[$i][1] = str_replace(\"FillinBlank\", \"<input type=\\"text\\" name=\\"textfield\".$row['QuestionId'].\"\\" />\", $Options[$i][1]);
}
$query = mysql_query(\"SELECT * FROM questions\");
for ($i = 1; $row = mysql_fetch_assoc($query); $i++)
{
echo \"<tr><td><strong>\".$row['QuestionId'].\".</strong> \".$row['Question'].\"</td></tr>\";
foreach ($Options as $key) {
if ($key[2] == $row['QuestionId'])
echo \"<tr><td><label><input type=\\"radio\\" name=\\"\".$row['QuestionId'].\"\\" value=\\"\".$key[0].\"\\" />\".$key[1].\"</label></td></tr>\";
}
}
<input type=\"submit\" value=\"Submit Quiz\" name=\"Submit\" />
</form>
</body>
</html>
?>
Now you can add addtional questions and answers via the PHPMySQL admin tool. I didn't write these the most efficent but it sounds like you need them today to the code provided should fine. Now all you have to do is write a processing Page that will take the results and submit them. Please let me know if you have any questions.
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 18:11 — 30th March 2007.
She has: 11,421 posts
Joined: Jun 1999
Yay! Great, that's working now: http://www.housing.uwaterloo.ca/surveys/quick-quiz2.php
So the next thing I need to figure out is how the form buttons would work...
Megan
Connect with us on Facebook!
ChadR posted this at 18:22 — 30th March 2007.
They have: 43 posts
Joined: Mar 2007
Do you just meant?
Or are you talking about processing the form and displaying the results?
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
ChadR posted this at 18:33 — 30th March 2007.
They have: 43 posts
Joined: Mar 2007
Megan,
It looks good but I put a string replace function in there if you FillinBlank in the Database for an answer it will automatically generate a textBox where they can fill that information in. Hopefully with the information that I've provided so far you can get it setup to add the results. You will probably have to create one more table for the Fill In the Blank results to get put in. That would only need an Id field, QuestionId field and VarChar field. Hopefully the rest is all P's and Q's from here on it. Have a wonderful weekend!
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 18:35 — 30th March 2007.
She has: 11,421 posts
Joined: Jun 1999
How to make it submit the results, I think. I have generated the input buttons and I wasn't sure what to do with those and how to process the from on the other end. Will it just be $_POST values like usual? I'm thinking yes???
I'm also not sure how to handle the fill in the blank questions. Should I have a conditional in there to put in text input boxes on the questions that need them?
Thanks for all your help!!!
Megan
Connect with us on Facebook!
ChadR posted this at 18:50 — 30th March 2007.
They have: 43 posts
Joined: Mar 2007
Well The FillinBlank String Replace should work for you. I don't have time to write the Processing Script Maybe sometime next week. No work on the weekends
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 15:08 — 4th April 2007.
She has: 11,421 posts
Joined: Jun 1999
Okay, I have this mostly working now. Here's the results page:
http://www.housing.uwaterloo.ca/surveys/quick-quiz_submit2.php
You can see that I have all the questions tabulating and displaying in tables. Now I need to calculate the percentage total for each answer. But how? This is the code I am using to display the results:
<?php
$questions = mysql_query(\"SELECT * FROM survey_quickquizW07_questions\") or die (\"Database Error\");
while($row = mysql_fetch_array($questions)) {
if ($row['questionType'] == \"multchoice\"){
echo \"<li>\" . $row['question'] . \"
<table>\" ;
$ID = $row['questionID'];
$optionsquery = mysql_query(\"SELECT * FROM survey_quickquizW07_options WHERE questionID=$ID\")
or die (\"Database Error\");
while($row = mysql_fetch_array($optionsquery)) {
echo \"\n\t\t<tr><td>\" . $row['optiontext'] . \"</td><td>\"
. $row['selected'] . \"</td></tr>\";
if ($row['optiontext'] == \"Other\") {
echo \"<tr><td colspan=\\"2\\"><strong>Other:</strong> text goes here</td></tr>\";
}
}
echo \"\n\t</table>\";
} else {
echo \"<li>\" . $row['question'] . \"
</li>\";
}
}
echo \"</ol>\";
?>
There are three tables in the database - one for the questions, one for the options, and one for the free text answers. The questions and options are connected by a questionID field. The options have a "selected" field which is incremented by 1 every time that option is selected (as ChadR described). The above code is a loop going through the data to show the "selected" values (I hope that's enough information!).
The problem is that I need a total for each question in order to calculate the percent for that question. I could gather an overall total for the entire quiz and store that in the database but that wouldn't be exactly accurate because they don't have to choose an answer for each question (they can skip some). Is there any way that I could get a total just for one specific question?
Megan
Connect with us on Facebook!
ChadR posted this at 16:35 — 4th April 2007.
They have: 43 posts
Joined: Mar 2007
I broke my train of though like 10x But there a couple of things that you should avoid here.
1. Your are doing a While Loop inside a While Loop this is extremely Bad! You are processing a lot of extra records.
2. You need to add a LEFT JOIN so you can get the Total Number of Votes.
3. Reading that text made me Dizzy Too many pretty whitespaces. What did you use to write it like that?
Here is my Code it should be right but like I said I got distracted a lot while writing so I definately wouldn't be surprised if there were errors
<?php
//Lets Get all the Questions and Put them into an array to avoid Putting a Loop inside a loop
// We will also use a LEFT JOIN to get the total number of votes for each question
$questions = mysql_query(\"SELECT q.*, SUM(o.Selected) as NumAnswered FROM `survey_quickquizW07_questions` q LEFT JOIN survey_quickquizW07_options o on o.QuestionId = q.QuestionId GROUP by o.QuestionID\") or die (\"Database Error\");
for ($i = 0; $row = mysql_fetch_assoc($questions); $i++)
{
$QuestionArray[$i][0] = $row['questionID'];
$QuestionArray[$i][1] = $row['question'];
$QuestionArray[$i][2] = $row['NumAnswered'];
}
$Count = count($QuestionArray);
for ($i = 0; $i < $Count; $i++)
{
echo \"<li>\" . $QuestionArray[$i][1] . \"<table>\";
$optionsquery = mysql_query(\"SELECT * FROM survey_quickquizW07_options WHERE questionID=\".$QuestionArray[$i][0].\"\") or die (\"Database Error\");
while($row = mysql_fetch_array($optionsquery))
{
$Per = $row['selected'] / $QuestionArray[$i][2] ;
echo \"<tr><td>\" . $row['optiontext'] . \"</td><td>\". $row['selected'] . \"</td><td>$Per</td></tr>\";
}
echo \"</table></li>\";
}
?>
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
ChadR posted this at 16:40 — 4th April 2007.
They have: 43 posts
Joined: Mar 2007
Maybe you will want to limit the % to decimals points as well you can use the Sprintf command to do so.
Just add
<?php
$Per = sprintf(\"%.2f\", $Per);
?>
After the $per variable is defined.
Let me know if I can be of any further assistance.
- Chad
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 18:02 — 4th April 2007.
She has: 11,421 posts
Joined: Jun 1999
Shoot, I really don't have time to understand that and I really don't like using code I don't understand. Oh well, might have to do it anyway
I don't have a row called NumAnswered - what is that for? Is that the same as "selected"??
Thanks for all your help though! I have that plugged in but now I need to re-figure out how to do all the free text entires. That's why there was that if ($row['questionType'] == "multchoice") conditional...
Megan
Connect with us on Facebook!
ChadR posted this at 18:20 — 4th April 2007.
They have: 43 posts
Joined: Mar 2007
Let me try to explain it to you.
the NumAnswered Calculates the total number of times that Question was responded to.
In this statement
<?php
$questions = mysql_query(\"SELECT q.*, SUM(o.Selected) as NumAnswered FROM `survey_quickquizW07_questions` q LEFT JOIN survey_quickquizW07_options o on o.QuestionId = q.QuestionId GROUP by o.QuestionID\") or die (\"Database Error\");
?>
.
I used a LEFT JOIN to add the SUM of all the numbers in the Selected Field for Options that matched the QuestionId So now you have a way to get a percentage out.
What do you want to Appear in the "Other" section? I didn't understand that. Also what do you want to appear in the Fill in the Blank Questions?
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 18:27 — 4th April 2007.
She has: 11,421 posts
Joined: Jun 1999
I have another table for the freetext answers. Each question, in the questions table, has a field for the questionType. My old code was splitting it so that the table of answers was generated only for the questions marked "multchoice". The "freetext" questions just pulled the contents of the freetext table. So I need to have the questionType field out of the questions database so I can show those questions too. The freeetext questions shouldn't have any matching answers in the options table.
What are all the q. and o. parts in the select query doing? That's what really confused me. There are "other" fields on some questions and 5 other questions that just have text entry boxes.
Megan
Connect with us on Facebook!
ChadR posted this at 18:40 — 4th April 2007.
They have: 43 posts
Joined: Mar 2007
the q. and o. are just shorten name. If you notice in the FROM part of the query there is a letter after the name of the table. It refers to the table alias much like when I do AS for the NumAnswered column. You could remove the alias after the table name but this just saves time.
So in Plain English
SELECT q.*, SUM(o.Selected) as NumAnswered FROM `survey_quickquizW07_questions` q LEFT JOIN survey_quickquizW07_options o on o.QuestionId = q.QuestionId GROUP by o.QuestionID
States...
Please show me all the columns in the table survery_quickquizW07_questions (q.*). Now match all the options with each Question (LEFT JOIN survey_quickquizW07_options o on o.QuestionId = q.QuestionId). Please add up all the items in the Selected Column that match each question and show it to me (SUM(o.Selected) as NumAnswered & GROUP by o.QuestionID).
I still don't understand What you going to do with the freetext questions. Are you going to show all the freetext questions answers?
If you only want to show the multiple choice questions you could do a WHERE statment in your Questions query
<?php
$questions = mysql_query(\"SELECT q.*, SUM(o.Selected) as NumAnswered FROM `survey_quickquizW07_questions` q LEFT JOIN survey_quickquizW07_options o on o.QuestionId = q.QuestionId WHERE q.questionType = 'multchoice' GROUP by o.QuestionID\") or die (\"Database Error\");
?>
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 18:56 — 4th April 2007.
She has: 11,421 posts
Joined: Jun 1999
Okay, that helps. Then I could do a separate query for the freetext questions. It won't order them the way I want them but I guess I might have to live with that.
I am going to try showing the answers to the freetext questions but only after I approve them. I have a separate admin area (that I'm also using for other things), where I go in and read the submissions and approve them. That process just updates an "approved" field in the freetext table. So the query for the freetext questions would only show the answers WHERE approved=1. I think i can work that out.
Megan
Connect with us on Facebook!
ChadR posted this at 19:02 — 4th April 2007.
They have: 43 posts
Joined: Mar 2007
There are other ways you could do it so that it could order them by Question ID (If you do want them ordered by QuestionId you should specify that in a ORDER BY clause) I am still unclear as to what you plan to do with the questions that are not freetext. Unless these results are monitored I would highly discourage allowing them to be displayed. This is a pretty large security threat and some people would surely get inappropriate. If you have questions about how I did something or why please let me know I willing to share with the community.
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Megan posted this at 19:25 — 4th April 2007.
She has: 11,421 posts
Joined: Jun 1999
No, they are being approved before they get posted. I have an admin area that I'm using for some other applications I bult. They have the same process - I log in, see a table of what has been submitted, check an approved field which updates an "approved" field in the database. Only the fields that have approved=1 will be diplayed, everything else is hidden.
I managed to write a separate query to show the freetext questions after the multiple choice. See the results here:
http://www.housing.uwaterloo.ca/surveys/quick-quiz_submit.php
(there's a lot of dummy text in there right now but it's mostly together)
Megan
Connect with us on Facebook!
ChadR posted this at 19:26 — 4th April 2007.
They have: 43 posts
Joined: Mar 2007
After re-reading your last post I noticed you will be administering them.
So I imaging you have an area in your freetext table that relates to the QuestionId field. You could just do the initial page I and after you do the table and after This Code
<?php
$optionsquery = mysql_query(\"SELECT * FROM survey_quickquizW07_options WHERE questionID=\".$QuestionArray[$i][0].\"\") or die (\"Database Error\");
while($row = mysql_fetch_array($optionsquery))
{
$Per = $row['selected'] / $QuestionArray[$i][2] ;
echo \"<tr><td>\" . $row['optiontext'] . \"</td><td>\". $row['selected'] . \"</td><td>$Per</td></tr>\";
}
?>
Add something like
<?php
$freetextquery = mysql_query(\"SELECT * FROM survey_quickquizW07_freetext WHERE questionID=\".$QuestionArray[$i][0].\" AND approved = 1\") or die (\"Database Error\");
while($row = mysql_fetch_array($freetextquery ))
{
//Show the results
}
?>
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
ChadR posted this at 19:28 — 4th April 2007.
They have: 43 posts
Joined: Mar 2007
It looks really good Megan! You are well on your way to being a PHP Developer!
Oh and I read your post on your blog about small fonts... Don't Look at my site *big grin*
The Best User Driven Poker Site, where you can find Poker Games in your area and get the latest Poker Strategy.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.