Browse Source

Change queries that fetch moments for a given experience

Victor Hernandez 4 years ago
parent
commit
b08d449b3c
2 changed files with 19 additions and 12 deletions
  1. 2
    1
      special2.php
  2. 17
    11
      viewExperience.php

+ 2
- 1
special2.php View File

98
 		
98
 		
99
 		
99
 		
100
 		// Create a new event for each moment
100
 		// Create a new event for each moment
101
-		$queryMoments = "SELECT * FROM `subquestionnair` WHERE id_questionnair IN (SELECT id_questionnair FROM `experience_questionnair` WHERE id_experience = '$experienceID');";
101
+		$queryMoments = "SELECT SQ.* FROM subquestionnair AS SQ JOIN experience_subquestionnair AS ES WHERE SQ.id = ES.id_subquestionnair AND ES.id_experience = '$experienceID';";
102
+// 		$queryMoments = "SELECT * FROM `subquestionnair` WHERE id_questionnair IN (SELECT id_questionnair FROM `experience_questionnair` WHERE id_experience = '$experienceID');";
102
 		$resultMoments = mysqli_query($connection, $queryMoments);
103
 		$resultMoments = mysqli_query($connection, $queryMoments);
103
 		while($rowMoments = mysqli_fetch_assoc($resultMoments)) {
104
 		while($rowMoments = mysqli_fetch_assoc($resultMoments)) {
104
 		
105
 		

+ 17
- 11
viewExperience.php View File

33
 		}
33
 		}
34
 		
34
 		
35
 	}
35
 	}
36
+	
37
+	// FETCH EXPERIENCE'S PROJECT ID
38
+	$queryProject = "SELECT id_project FROM project_experience WHERE id_experience = '$experienceID';";
39
+	$resultProject = mysqli_query($connection, $queryProject);
40
+	$rowProject = mysqli_fetch_assoc($resultProject);
41
+
36
 
42
 
37
 	include_once 'header.php';
43
 	include_once 'header.php';
38
 	
44
 	
263
 					<div class="col-sm-12">
269
 					<div class="col-sm-12">
264
 						<?php
270
 						<?php
265
 						
271
 						
266
-  							$query4 = "SELECT * FROM subquestionnair WHERE `id_questionnair` IN (SELECT `id_questionnair` FROM experience_questionnair WHERE `id_experience` = '$experienceID') ORDER BY date_to_administer ASC;";
272
+//   							$query4 = "SELECT * FROM subquestionnair WHERE `id_questionnair` IN (SELECT `id_questionnair` FROM experience_questionnair WHERE `id_experience` = '$experienceID') ORDER BY date_to_administer ASC;";
273
+  							$query4 = "SELECT SQ.* FROM subquestionnair AS SQ JOIN experience_subquestionnair AS ES WHERE SQ.id = ES.id_subquestionnair AND ES.id_experience = '$experienceID' ORDER BY SQ.date_to_administer ASC;";
267
 							$result4 = mysqli_query($connection, $query4);
274
 							$result4 = mysqli_query($connection, $query4);
268
 							
275
 							
269
 							// IF THE EXPERIENCE HAS AT LEAST ONE MOMENT ASSOCIATED TO IT, SHOW IT
276
 							// IF THE EXPERIENCE HAS AT LEAST ONE MOMENT ASSOCIATED TO IT, SHOW IT
975
  						<div class='modal-body'>
982
  						<div class='modal-body'>
976
 
983
 
977
 							<div class="form-horizontal">
984
 							<div class="form-horizontal">
978
-							
985
+		
986
+								<!-- EXPERIENCE ID -->					
979
 								<input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>" required>
987
 								<input type="hidden" name="id_experience" value="<?php echo $experienceID; ?>" required>
988
+								
989
+
990
+								<!-- PROJECT ID (0 IF THERE'S NONE) -->
991
+								<input type="hidden" name="projectID" value="<?php echo ($rowProject['id_project'] ? $rowProject['id_project'] : 0); ?>" required>
992
+							
980
 							
993
 							
981
 								<div class="row">
994
 								<div class="row">
982
 									<div class="col-sm-12">
995
 									<div class="col-sm-12">
1045
 							<br>
1058
 							<br>
1046
 							
1059
 							
1047
 
1060
 
1048
-							<?php
1049
-								$queryProject = "SELECT id_project FROM project_experience WHERE id_experience = '$experienceID';";
1050
-								$resultProject = mysqli_query($connection, $queryProject);
1051
-								$rowProject = mysqli_fetch_assoc($resultProject);
1052
-							?>
1053
-							<!-- PROJECT ID (EMPTY STRING IF THERE'S NONE) -->
1054
-							<input type="hidden" name="projectID" value="<?php echo $rowProject['id_project']; ?>">
1055
-							
1056
-							
1061
+							<!-- PROJECT ID (0 IF THERE'S NONE) -->
1062
+							<input type="hidden" name="projectID" value="<?php echo ($rowProject['id_project'] ? $rowProject['id_project'] : 0); ?>">
1057
 							
1063
 							
1058
 							
1064
 							
1059
 							<!-- FROM QUESTIONNAIRE -->
1065
 							<!-- FROM QUESTIONNAIRE -->