Your entry has been saved!"; $result = mysqli_query($GLOBALS['conn'],$sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysqli_error($GLOBALS['conn']); exit; } } else { $message .= "
Please type an entry to your relaxation log before submitting!"; } } $prevNotes = array(); //Check to see if user has any previous relaxation log entries.... $sql = 'SELECT count(answer) as count from answers where uid=' . $GLOBALS['locationinfo']['uid'] . ' AND qid=' . $qid; $result = mysqli_query($GLOBALS['conn'],$sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysqli_error($GLOBALS['conn']); exit; } $row =mysqli_fetch_assoc($result); $numoftimesanswered = $row['count']; mysqli_free_result($result); if ($numoftimesanswered > 0) { //There are previous relaxation log entries and thus values can be filled in... $sql = 'SELECT timestamp, answer from answers where uid=' . $GLOBALS['locationinfo']['uid'] . ' AND qid=' . $qid . ' order by timestamp'; $result = mysqli_query($GLOBALS['conn'],$sql); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysqli_error($GLOBALS['conn']); exit; } //$row =mysqli_fetch_assoc($result); $i = 0; while ($thisrow=mysqli_fetch_row($result)) { $prevNotes[$i] = $thisrow; $i++; } //list($person1, $person2, $person3, $person4, $person5) = explode("::", $answer); //$goalAnswers = explode("::", $answer); mysqli_free_result($result); } else { //The question has not been answered before, so values are empty... $prevNotes = array(); } //At this point, all previous notes and their date and time are contained in array called prevNotes foreach($prevNotes as $pn) { $pn[0] = strtotime($pn[0]); $pn[0] = date('F j, Y g:i a', $pn[0]); } ?>

Relaxation Log:

'; ?>

     

Image of Relaxation Log
'.$pn[0].'

'.$pn[1].'

'; } ?>
Image of Relaxation Log