-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmodal_edit.php
153 lines (137 loc) · 4.97 KB
/
modal_edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
include("db.php");
if (isset($_REQUEST['id']) ){
$id= $_REQUEST['id'];
?>
<div class="btn-group pull-right"">
<button type="button" class="btn btn-info btn-sm " data-toggle="modal" data-target="#add" id="add_q" data-id="<?php echo $id; ?>">Add Question</button>
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#editq">Edit Question</button>
<button type="button" class="btn btn-info btn-sm" data-toggle="modal" data-target="#edittitle">Edit Survey Title</button>
</div>
<br><br>
<?php
$sql = mysqli_query($con,"SELECT * FROM `survey_questionnaire` WHERE survey_ID = $id");
$sql1 = mysqli_query($con,"SELECT * FROM `survey` WHERE survey_ID = $id");
$i = 1;
$title = mysqli_fetch_array($sql1);
?>
<h1 class="text-center"><?php echo $title['survey_name']?></h1>
<form action="">
<?php
while ($data = mysqli_fetch_array($sql)){
$i;
$q_ID = $data[0];
$sql1 = mysqli_query($con,"SELECT GROUP_CONCAT(answer) AS `option`
FROM `survey_anweroptions` WHERE survey_qID = $q_ID");
$data1 = mysqli_fetch_array($sql1);
$question = $data['question'];
$option = $data1['option'];
$option = explode(",",$option);
?>
<div class="form-group">
<label for=""><?php echo $i.".) ".$question ?> </label>
<select class="form-control">
<?php
foreach ($option as $key => $value) {
?>
<option><?php echo$value ?></option>
<?php
}
?>
</select>
</div>
<?php
$i++;
}
?>
</form>
<?php
}
?>
<div id="editq" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header bg-info">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit Question</h4>
</div>
<div class="modal-body">
<form action="action/survey">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Select Question</label>
<div class="col-sm-10">
<select class="form-control" id="mySelect" onchange="option()">
<?php
$sql = mysqli_query($con,"SELECT *,(SELECT GROUP_CONCAT(answer) AS `option`FROM `survey_anweroptions` WHERE survey_qID = sq.survey_qID) `option` FROM `survey_questionnaire`sq WHERE sq.survey_ID = $id");
while ($q = mysqli_fetch_array($sql)) {
?>
<option value="<?php echo $q[0]?>"><?php echo $q[2]?></option>
<?php
}
?>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label " for=""></label>
</div>
<?php
$sql = mysqli_query($con,"SELECT *,(SELECT GROUP_CONCAT(answer) AS `option`FROM `survey_anweroptions` WHERE survey_qID = sq.survey_qID) `option` FROM `survey_questionnaire`sq WHERE sq.survey_ID = 1 AND survey_qID = 1");
$d1= mysqli_fetch_array($sql);
?>
<div class="form-group">
<label class="control-label col-sm-2" for="">Question</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="" placeholder="" value="<?php echo $d1[2]?>">
</div>
</div>
<?php
$variable = $d1[3];
$z = 1;
$piece = explode(",", $variable);
foreach ($piece as $key => $value) {
?>
<div class="form-group">
<label class="control-label col-sm-2" for="">Option <?php echo $z?> </label>
<div class="col-sm-10">
<input type="text" class="form-control" id="" placeholder="" value="<?php echo $value?>">
</div>
</div>
<?php
$z++;
}
?>
<div class="text-center">
<button type="submit" class="btn btn-default" name="">Update</button>
</div>
</form>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
<div id="edittitle" class="modal fade" role="dialog">
<div class="modal-dialog modal-lg">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header bg-success">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Edit Title</h4>
</div>
<div class="modal-body">
<form method="POST" action="action/survey">
<input type="hidden" name="ID" value="<?php echo $id?>">
<div class="form-group">
<label for="Title">Title</label>
<input type="text" class="form-control" id="tilte" name="surveyname" value="<?php echo $title['survey_name']?>">
</div>
<button type="submit" class="btn btn-default" name="update-surveyName">Submit</button>
</form>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>