/
st-register.php
100 lines (100 loc) · 3.68 KB
/
st-register.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
<?php
include_once('db/Database.php');
?>
<!DOCTYPE html>
<html>
<head lang="en">
<link href="assets/css/bootstrap.css" type="text/css" rel="stylesheet">
<title></title>
</head>
<body>
<div class="container" style="margin-top: 10px;">
<div class="row">
<div class="col-md-5 col-md-offset-2">
<?php
$db = new Database();
$ids = $db->get_all_student_ids();
?>
<select class="form-control" id="student_id">
<option>Select Id</option>
<?php
foreach($ids as $id) {
echo "<option value='$id'>".$id."</option>";
}
?>
</select>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2" style="margin-top: 10px;">
<button type="button" class="btn btn-primary" id="edit">Edit</button>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2" style="margin-top: 10px;">
<form class="form-horizontal" role="form">
<div class="form-body">
<div class="form-group">
<label class="col-md-3 control-label">Student Name</label>
<div class="col-md-4">
<input type="text" class="form-control" id="student_name" />
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Age</label>
<div class="col-md-4">
<input type="text" class="form-control" id="age" />
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Gender</label>
<div class="col-md-4">
<select class="form-control" id="gender">
<option>Select Gender</option>
<option value="m">Male</option>
<option value="f">Female</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label">Address</label>
<div class="col-md-4">
<textarea id="address" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-4 col-md-offset-3">
<button class="btn btn-primary">Save & Continue</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
<script src="assets/js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#edit").click(function() {
$.ajax({
url: "student.php",
type: "GET",
dataType: "JSON",
data: {
get_student_info:true,
student_id: $("#student_id").val()
},
success: function (data) {
if(data.count==1) {
$("#student_name").val(data.st_name);
$("#age").val(data.st_age);
$("#gender").val(data.st_gender);
$("#address").val(data.st_address);
}
}
});
});
});
</script>