<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1037964" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1037964</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217412</link>
    <description> &lt;p&gt;It looks really good Megan!  You are well on your way to being a PHP Developer!&lt;/p&gt;
&lt;p&gt;Oh and I read your post on your blog about small fonts... Don&#039;t Look at my site *big grin*&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 19:28:55 +0000</pubDate>
 <dc:creator>ChadR</dc:creator>
 <guid isPermaLink="false">comment 1217412 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217411</link>
    <description> &lt;p&gt;After re-reading your last post I noticed you will be administering them.&lt;/p&gt;
&lt;p&gt;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&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$optionsquery &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_query&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;SELECT * FROM survey_quickquizW07_options WHERE questionID=\&quot;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$QuestionArray&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;[0].\&quot;\&quot;) or die (\&quot;Database Error\&quot;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;while(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = mysql_fetch_array(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$optionsquery&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;)) &lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$Per&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;selected&#039;] / &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$QuestionArray&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;[2] ;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;echo \&quot;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;\&quot; . &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;optiontext&#039;] . \&quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;\&quot;. &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;selected&#039;] . \&quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$Per&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;\&quot;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Add something like&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$freetextquery &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_query&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;SELECT * FROM survey_quickquizW07_freetext WHERE questionID=\&quot;.&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$QuestionArray&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;[0].\&quot; AND approved = 1\&quot;) or die (\&quot;Database Error\&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;while(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$row&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; = mysql_fetch_array(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$freetextquery&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt; )) &lt;br /&gt;{&lt;br /&gt;//Show the results&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 19:26:46 +0000</pubDate>
 <dc:creator>ChadR</dc:creator>
 <guid isPermaLink="false">comment 1217411 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217410</link>
    <description> &lt;p&gt;No, they are being approved before they get posted. I have an admin area that I&#039;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 &quot;approved&quot; field in the database. Only the fields that have approved=1 will be diplayed, everything else is hidden. &lt;/p&gt;
&lt;p&gt;I managed to write a separate query to show the freetext questions after the multiple choice. See the results here:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.housing.uwaterloo.ca/surveys/quick-quiz_submit.php&quot; class=&quot;bb-url&quot;&gt;http://www.housing.uwaterloo.ca/surveys/quick-quiz_submit.php&lt;/a&gt;&lt;br /&gt;
(there&#039;s a lot of dummy text in there right now but it&#039;s mostly together)&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 19:25:14 +0000</pubDate>
 <dc:creator>Megan</dc:creator>
 <guid isPermaLink="false">comment 1217410 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217409</link>
    <description> &lt;p&gt;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.&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 19:02:29 +0000</pubDate>
 <dc:creator>ChadR</dc:creator>
 <guid isPermaLink="false">comment 1217409 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217408</link>
    <description> &lt;p&gt;Okay, that helps. Then I could do a separate query for the freetext questions. It won&#039;t order them the way I want them but I guess I might have to live with that.&lt;/p&gt;
&lt;p&gt;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&#039;m also using for other things), where I go in and read the submissions and approve them. That process just updates an &quot;approved&quot; 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.&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 18:56:11 +0000</pubDate>
 <dc:creator>Megan</dc:creator>
 <guid isPermaLink="false">comment 1217408 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217407</link>
    <description> &lt;p&gt;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 &lt;em&gt;table alias&lt;/em&gt; much like when I do AS for the NumAnswered column.  You could remove the alias after the table name but this just saves time.&lt;/p&gt;
&lt;p&gt;So in Plain English&lt;/p&gt;
&lt;p&gt;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&lt;/p&gt;
&lt;p&gt;States...&lt;/p&gt;
&lt;p&gt;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  &amp;amp; GROUP by o.QuestionID).&lt;/p&gt;
&lt;p&gt;I still don&#039;t understand What you going to do with the freetext questions.  Are you going to  show all the freetext questions answers? &lt;/p&gt;
&lt;p&gt;If you only want to show the multiple choice questions you could do a WHERE statment in your Questions query&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$questions &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_query&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;SELECT q.*, SUM(o.Selected) as NumAnswered FROM `survey_quickquizW07_questions` q LEFT JOIN survey_quickquizW07_options&amp;nbsp; o on o.QuestionId = q.QuestionId WHERE q.questionType = &#039;multchoice&#039; GROUP by o.QuestionID\&quot;) or die (\&quot;Database Error\&quot;);&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 18:40:46 +0000</pubDate>
 <dc:creator>ChadR</dc:creator>
 <guid isPermaLink="false">comment 1217407 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217406</link>
    <description> &lt;p&gt;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 &quot;multchoice&quot;. The &quot;freetext&quot; 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&#039;t have any matching answers in the options table.&lt;/p&gt;
&lt;p&gt;What are all the q. and o. parts in the select query doing? That&#039;s what really confused me. There are &quot;other&quot; fields on some questions and 5 other questions that just have text entry boxes.&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 18:27:52 +0000</pubDate>
 <dc:creator>Megan</dc:creator>
 <guid isPermaLink="false">comment 1217406 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217405</link>
    <description> &lt;p&gt;Let me try to explain it to you.&lt;/p&gt;
&lt;p&gt;the NumAnswered Calculates the total number of times that Question was responded to.  &lt;/p&gt;
&lt;p&gt;In this statement&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$questions &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;mysql_query&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;SELECT q.*, SUM(o.Selected) as NumAnswered FROM `survey_quickquizW07_questions` q LEFT JOIN survey_quickquizW07_options&amp;nbsp; o on o.QuestionId = q.QuestionId GROUP by o.QuestionID\&quot;) or die (\&quot;Database Error\&quot;);&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
.&lt;br /&gt;
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.&lt;/p&gt;
&lt;p&gt;What do you want to Appear in the &quot;Other&quot; section?  I didn&#039;t understand that.  Also what do you want to appear in the Fill in the Blank Questions?&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 18:20:00 +0000</pubDate>
 <dc:creator>ChadR</dc:creator>
 <guid isPermaLink="false">comment 1217405 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217403</link>
    <description> &lt;p&gt;Shoot, I really don&#039;t have time to understand that and I &lt;em&gt;really&lt;/em&gt; don&#039;t like using code I don&#039;t understand. Oh well, might have to do it anyway &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/sad.png&quot; title=&quot;Sad&quot; alt=&quot;Sad&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;I don&#039;t have a row called NumAnswered - what is that for? Is that the same as &quot;selected&quot;??&lt;/p&gt;
&lt;p&gt;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&#039;s why there was that   if ($row[&#039;questionType&#039;] == &quot;multchoice&quot;) conditional...&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 18:02:19 +0000</pubDate>
 <dc:creator>Megan</dc:creator>
 <guid isPermaLink="false">comment 1217403 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/help-tabulating-survey-data#comment-1217399</link>
    <description> &lt;p&gt;Maybe you will want to limit the % to decimals points as well you can use the Sprintf command to do so.&lt;/p&gt;
&lt;p&gt;Just add&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$Per &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;sprintf&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;%.2f\&quot;, &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$Per&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;);&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;After the $per variable is defined.&lt;/p&gt;
&lt;p&gt;Let me know if I can be of any further assistance.&lt;/p&gt;
&lt;p&gt;- Chad&lt;/p&gt;
 </description>
     <pubDate>Wed, 04 Apr 2007 16:40:14 +0000</pubDate>
 <dc:creator>ChadR</dc:creator>
 <guid isPermaLink="false">comment 1217399 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
