Skip to content

Commit

Permalink
Fixed error in SQL logic. Brain working now. Uses "IN" and "( ??? OR …
Browse files Browse the repository at this point in the history
…???)" to determine results, rather than straight "AND" between conditions.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@37 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Mar 16, 2003
1 parent 1b12b95 commit fca933e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions admin/statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,24 +252,32 @@
{
if ($pv != "sid" && $pv != "display" && substr($pv, 0, 1) != "M") //pull out just the fieldnames
{
$thisquestion = "$pv IN (";
foreach ($$pv as $condition)
{
$selects[]="$pv = '$condition'";
$thisquestion .= "'$condition', ";
}
$thisquestion = substr($thisquestion, 0, -2);
$thisquestion .= ")";
$selects[]=$thisquestion;
}
elseif (substr($pv, 0, 1) == "M")
{
list($lsid, $lgid, $lqid) = explode("X", $pv);
$aquery="SELECT code FROM answers WHERE qid=$lqid";
$aresult=mysql_query($aquery) or die ("Couldn't get answers<br />$aquery<br />".mysql_error());
while ($arow=mysql_fetch_row($aresult))
while ($arow=mysql_fetch_row($aresult)) // go through every possible answer
{
if (in_array($arow[0], $$pv))
if (in_array($arow[0], $$pv)) // only add condition if answer has been chosen
{
$selects[]=substr($pv, 1, strlen($pv))."$arow[0] = 'Y'";
$mselects[]=substr($pv, 1, strlen($pv))."$arow[0] = 'Y'";
}
}

if ($mselects)
{
$thismulti=implode(" OR ", $mselects);
$selects[]="($thismulti)";
}
}
}
// 2: Do SQL query
Expand Down

0 comments on commit fca933e

Please sign in to comment.