From 6788638d68e65f6e5b6a76971e6a7db8a0ec55b4 Mon Sep 17 00:00:00 2001 From: azammitdcarf Date: Mon, 16 Feb 2009 05:34:04 +0000 Subject: [PATCH] Removed reliance on next() which is unreliable --- functions/functions.limesurvey.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/functions/functions.limesurvey.php b/functions/functions.limesurvey.php index 26d72432..03d5a71e 100644 --- a/functions/functions.limesurvey.php +++ b/functions/functions.limesurvey.php @@ -518,11 +518,15 @@ function limesurvey_export_fixed_width($questionnaire_id,$sample_import_id = fal if ($sample_import_id == false) { $sql .= " AND ("; + $ccount = count($r); + $ccounter = 0; foreach($r as $row) { $token = $row['case_id']; + $ccounter++; $sql .= " token = '$token'"; - if (next($r)) $sql .= " or "; + if ($ccounter < $ccount) + $sql .= " or "; } $sql .= ")"; } @@ -539,11 +543,15 @@ function limesurvey_export_fixed_width($questionnaire_id,$sample_import_id = fal if (!empty($r)) { $sql .= " AND ("; + $ccount = count($r); + $ccounter = 0; foreach($r as $row) { $token = $row['case_id']; + $ccounter++; $sql .= " token = '$token'"; - if (next($r)) $sql .= " or "; + if ($ccounter < $ccount) + $sql .= " or "; } $sql .= ")"; } @@ -551,7 +559,7 @@ function limesurvey_export_fixed_width($questionnaire_id,$sample_import_id = fal } $r = $ldb->GetAll($sql); - + foreach($r as $Row) { foreach ($varwidth as $var => $width)