public function find_previous_surveys($scope, $survey_type) { include "../include/dbconnopen.php"; // Ensure parameters are safe to be in a query (although they should be) $scope_sqlsafe = mysqli_real_escape_string($cnnEnlace, $scope); $survey_type_sqlsafe = mysqli_real_escape_string($cnnEnlace, $survey_type); $impact_assessment_search = "SELECT * FROM Assessments WHERE Date_Logged >= DATE_SUB(now(), INTERVAL " . $scope_sqlsafe . " MONTH) AND Participant_ID='" . $this->participant_id . "' ORDER BY Date_Logged DESC"; $impact_assessments = mysqli_query($cnnEnlace, $impact_assessment_search); if (!$impact_assessments) { return array(); // Bail out, we've not found any } // Build an array of all the results $assessments = array(); while ($assessment = mysqli_fetch_array($impact_assessments)) { $assessments[] = Assessment::createFromDatabase($assessment); } return $assessments; }