Skip to content

Commit

Permalink
Fixed bug that caused export of extended answers to fail, error in co…
Browse files Browse the repository at this point in the history
…nverting numerical data reference to explicit - type instead of qid

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@63 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Mar 18, 2003
1 parent d70be6c commit 057c453
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions admin/export.php
Expand Up @@ -94,8 +94,6 @@
}
else
{
//header("Content-Type: application/vnd.ms-excel"); //EXCEL FILE
//header("Content-Type: application/msword"); //EXPORT INTO MSWORD
if ($type == "doc") {header("Content-Disposition: attachment; filename=survey.doc");}
elseif ($type == "xls") {header("Content-Disposition: attachment; filename=survey.xls");}
elseif ($type == "csv") {header("Content-Disposition: attachment; filename=survey.csv");}
Expand Down Expand Up @@ -181,37 +179,43 @@
$legitqs[] = "DUMMY ENTRY";
while ($lw = mysql_fetch_array($lr))
{
$legitqs[] = $lw[0];
$legitqs[] = $lw[0]; //this creates an array of question id's'
}

$surveytable = "survey_{$sid}";
if ($_POST['sql'])

if ($_POST['sql']) //this applies if export has been called from the statistics package
{
$dquery = "SELECT * FROM $surveytable WHERE ".stripcslashes($_POST['sql'])." ORDER BY id";
}
else
else // this applies for exporting everything
{
$dquery = "SELECT * FROM $surveytable ORDER BY id";
}
$dresult = mysql_query($dquery);
$fieldcount = mysql_num_fields($dresult);
while ($drow = mysql_fetch_array($dresult))
{
if ($answers == "short") {echo implode($s, str_replace("\r\n", " ", $drow)) . "\n";}
if ($answers == "short")
{
echo implode($s, str_replace("\r\n", " ", $drow)) . "\n"; //create dump from each row
}

elseif ($answers == "long")
{
$i = 0;
for ($i; $i<$fieldcount; $i++)
{
list($fsid, $fgid, $fqid) = split("X", mysql_field_name($dresult, $i));
if (!$fqid) {$fqid = 0;}
while (!in_array($fqid, $legitqs))
while (!in_array($fqid, $legitqs)) //checks that the qid exists in our list
{
$fqid = substr($fqid, 0, strlen($fqid)-1);
}
$qq = "SELECT type FROM questions WHERE qid=$fqid";
$qr = mysql_query($qq);
while ($qrow = mysql_fetch_array($qr))
{$ftype = $qrow['qid'];}
{$ftype = $qrow['type'];}
switch ($ftype)
{
case "L": //DROPDOWN LIST
Expand Down

0 comments on commit 057c453

Please sign in to comment.