";
print "";
print "
Date |
Tired |
Hungry |
Anxious |
Sad |
Excited |
";
while($row = mysqli_fetch_array($r, MYSQLI_BOTH)){
// Display previous data
// In a table, we print a colored square if the person endorsed the item.
// Otherwise, we present nothing.
print "";
print "$row[5] | ";
if($row[0]>=1){
print " | ";
}else{
print " | ";
}
if($row[1]>=1){
print " | ";
}else{
print " | ";
}
if($row[2]>=1){
print " | ";
}else{
print " | ";
}
if($row[3]>=1){
print " | ";
}else{
print " | ";
}
if($row[4]>=1){
print " | ";
}else{
print " | ";
}
print " ";
// Computations to summarize data
// Simply add one to a running total for each emotion state each time it occurs.
$mood1 = $mood1 + $row[0];
$mood2 = $mood2 + $row[1];
$mood3 = $mood3 + $row[2];
$mood4 = $mood4 + $row[3];
$mood5 = $mood5 + $row[4];
// Update number of observations so we can compute
// a percentage later.
$n_observations = $n_observations + 1;
} // end while
// Compute proportion of times the person reported each affective state.
$mood1 = round($mood1/$n_observations,2);
$mood2 = round($mood2/$n_observations,2);
$mood3 = round($mood3/$n_observations,2);
$mood4 = round($mood4/$n_observations,2);
$mood5 = round($mood5/$n_observations,2);
// Display summaries
print "";
print "Overall | ";
print "$mood1 | ";
print "$mood2 | ";
print "$mood3 | ";
print "$mood4 | ";
print "$mood5 | ";
print " ";
print " ";
print " |
";
print "