Selaa lähdekoodia

Change queries that fetch moments for a given experience

Victor Hernandez 4 vuotta sitten
vanhempi
commit
b08d449b3c
2 muutettua tiedostoa jossa 19 lisäystä ja 12 poistoa
  1. 2
    1
      special2.php
  2. 17
    11
      viewExperience.php

+ 2
- 1
special2.php Näytä tiedosto

@@ -98,7 +98,8 @@
98 98
 		
99 99
 		
100 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 103
 		$resultMoments = mysqli_query($connection, $queryMoments);
103 104
 		while($rowMoments = mysqli_fetch_assoc($resultMoments)) {
104 105
 		

+ 17
- 11
viewExperience.php Näytä tiedosto

@@ -33,6 +33,12 @@
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 43
 	include_once 'header.php';
38 44
 	
@@ -263,7 +269,8 @@
263 269
 					<div class="col-sm-12">
264 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 274
 							$result4 = mysqli_query($connection, $query4);
268 275
 							
269 276
 							// IF THE EXPERIENCE HAS AT LEAST ONE MOMENT ASSOCIATED TO IT, SHOW IT
@@ -975,8 +982,14 @@
975 982
  						<div class='modal-body'>
976 983
 
977 984
 							<div class="form-horizontal">
978
-							
985
+		
986
+								<!-- EXPERIENCE ID -->					
979 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 994
 								<div class="row">
982 995
 									<div class="col-sm-12">
@@ -1045,15 +1058,8 @@
1045 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 1065
 							<!-- FROM QUESTIONNAIRE -->