-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit.php
55 lines (54 loc) · 2.23 KB
/
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
<?php
include 'header.php';
include 'config.php';
?>
<div id="main-content">
<h2>Update Record</h2>
<?php
$stu_id = $_GET['id'];
$readForUpdateQuery = "SELECT * FROM student WHERE sid = '{$stu_id}'";
$readForUpdateQueryResult = mysqli_query($conn,$readForUpdateQuery) or die("Query Failed");
if (mysqli_num_rows($readForUpdateQueryResult)>0) {
while ($readUp = mysqli_fetch_assoc($readForUpdateQueryResult)) { ?>
<form class="post-form" action="updatedata.php" method="post">
<div class="form-group">
<label>Name</label>
<input type="hidden" name="sid" value="<?php echo $readUp['sid']; ?>"/>
<input type="text" name="sname" value="<?php echo $readUp['sname']; ?>"/>
</div>
<div class="form-group">
<label>Address</label>
<input type="text" name="saddress" value="<?php echo $readUp['saddress']; ?>"/>
</div>
<div class="form-group">
<label>Class</label>
<select name="sclass">
<?php
$selectbQuery = "SELECT * FROM studentclass";
$selectbResult = mysqli_query($conn,$selectbQuery) or die("Query Not Found.");
if (mysqli_num_rows($selectbResult)>0) {
while ($class = mysqli_fetch_assoc($selectbResult)) {
if($readUp['sclass'] == $class['cid']){ ?>
<option selected value="<?php echo $class['cid']; ?>"><?php echo $class['cname']; ?></option>
<?php }
else{ ?>
<option value="<?php echo $class['cid']; ?>"><?php echo $class['cname']; ?></option>
<?php }
}
}
?>
</select>
</div>
<div class="form-group">
<label>Phone</label>
<input type="text" name="sphone" value="<?php echo $readUp['sphone']; ?>"/>
</div>
<input class="submit" type="submit" value="Update"/>
</form>
<?php }
}
?>
</div>
</div>
</body>
</html>