<?php include "../util.inc"; include 'surcom.inc'; // Open the survey. $surid = substr($_SERVER['PATH_INFO'], 1); $surdef = open_sur($surid); // Open the database. $dbm = @dba_open("$surv_loc/results", "r", 'db4'); if(!$dbm) whap('Database Open Failed', 'We are sorry, but your survey could not be found '. 'due to trouble on the server. Please try again '. 'later.'); // First line of file is name of survey. Read it, then start generating // HTML for the survey results. $title = fgets($surdef, 40); start("Results of the $title"); echo "Here are the present totals for the $title.<p><table>"; // One line per question, separated by ':'. Generate each question // as a line in a table. $qno = 1; // Question numbers. while(! feof($surdef)) { // Get the line and split it into parts. $line = fgets($surdef, 1024); $parts = explode(':', $line); // Generate the question. $ques = htmlspecialchars(array_shift($parts)); echo "<tr align=\"left\" valign=\"top\"><td>$ques</td>"; // Generate the response alternative counts. $rno = 1; echo "<td align=\"left\" valign=\"top\">"; foreach($parts as $resp) { $resp = htmlspecialchars($resp); $resp = preg_replace('/ /', ' ', $resp); if($rno > 1) echo " \n"; $key = "$surid+$qno+$rno"; if(dba_exists($key, $dbm)) $count = dba_fetch($key, $dbm); else $count = 0; echo "<nobr>$resp: $count</nobr>"; ++$rno; } echo "</td></tr>\n"; ++$qno; } dba_close($dbm); fclose($surdef); // Close the HTML stuff. echo "</table></body></html>\n"; ?>