jlimited
02-26-2007, 01:41 AM
Hello,
I have a interesting issue that is most likely a easy fix.
When I send a URL endcode to Script 1 it works great.
When I loop the $grp variable using a while/endwhile command (Script 2), it displays 4 sets of the calculations, but the results of the calculations are all the same.
I am not sure if the fix is to destroy the array $answer at the end of the calculations. If that seems logical, then how would I do that?
Script 1
$grp = $_GET["group"];
include '/home/jlimited/public_html/thesis/.db.php';
$completed = mysql_query("SELECT * FROM participants WHERE age!='999' AND complete='1'")
or die("Invalid query: " . mysql_error());
$pcount = mysql_num_rows($completed);
$pid = 1;
while($row = mysql_fetch_array($completed)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$sub = mysql_query("SELECT * FROM answers WHERE sid='$sid' AND grpvalue='$grp'")
or die("Invalid query: " . mysql_error());
$qcount = mysql_num_rows($sub);
$qid = 1;
while($items = mysql_fetch_array($sub)){
foreach( $items AS $key => $val ){
$$key = stripslashes( $val );
}
$answer[$qid][$pid] = $answervalue;
$qid++;
}
$pid++;
}
Script 2
include '/home/jlimited/public_html/thesis/.db.php';
$completed = mysql_query("SELECT * FROM participants WHERE age!='999' AND complete='1'")
or die("Invalid query: " . mysql_error());
$pcount = mysql_num_rows($completed);
$grp = 1;
while ($grp <= 4):
$pid = 1;
while($row = mysql_fetch_array($completed)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$sub = mysql_query("SELECT * FROM answers WHERE sid='$sid' AND grpvalue='$grp'")
or die("Invalid query: " . mysql_error());
$qcount = mysql_num_rows($sub);
$qid = 1;
while($items = mysql_fetch_array($sub)){
foreach( $items AS $key => $val ){
$$key = stripslashes( $val );
}
$answer[$qid][$pid] = $answervalue;
$qid++;
}
$pid++;
}
echo $qcount."<br>";
echo calpha($qcount,$pcount,$answer)."<br>";
echo mean($qcount,$pcount,$answer)."<br>";
echo sd($qcount,$pcount,$answer)."<br><br>";
$grp++;
endwhile;
Thanks
Jlimited
I have a interesting issue that is most likely a easy fix.
When I send a URL endcode to Script 1 it works great.
When I loop the $grp variable using a while/endwhile command (Script 2), it displays 4 sets of the calculations, but the results of the calculations are all the same.
I am not sure if the fix is to destroy the array $answer at the end of the calculations. If that seems logical, then how would I do that?
Script 1
$grp = $_GET["group"];
include '/home/jlimited/public_html/thesis/.db.php';
$completed = mysql_query("SELECT * FROM participants WHERE age!='999' AND complete='1'")
or die("Invalid query: " . mysql_error());
$pcount = mysql_num_rows($completed);
$pid = 1;
while($row = mysql_fetch_array($completed)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$sub = mysql_query("SELECT * FROM answers WHERE sid='$sid' AND grpvalue='$grp'")
or die("Invalid query: " . mysql_error());
$qcount = mysql_num_rows($sub);
$qid = 1;
while($items = mysql_fetch_array($sub)){
foreach( $items AS $key => $val ){
$$key = stripslashes( $val );
}
$answer[$qid][$pid] = $answervalue;
$qid++;
}
$pid++;
}
Script 2
include '/home/jlimited/public_html/thesis/.db.php';
$completed = mysql_query("SELECT * FROM participants WHERE age!='999' AND complete='1'")
or die("Invalid query: " . mysql_error());
$pcount = mysql_num_rows($completed);
$grp = 1;
while ($grp <= 4):
$pid = 1;
while($row = mysql_fetch_array($completed)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
$sub = mysql_query("SELECT * FROM answers WHERE sid='$sid' AND grpvalue='$grp'")
or die("Invalid query: " . mysql_error());
$qcount = mysql_num_rows($sub);
$qid = 1;
while($items = mysql_fetch_array($sub)){
foreach( $items AS $key => $val ){
$$key = stripslashes( $val );
}
$answer[$qid][$pid] = $answervalue;
$qid++;
}
$pid++;
}
echo $qcount."<br>";
echo calpha($qcount,$pcount,$answer)."<br>";
echo mean($qcount,$pcount,$answer)."<br>";
echo sd($qcount,$pcount,$answer)."<br><br>";
$grp++;
endwhile;
Thanks
Jlimited