-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
62 lines (57 loc) · 2.39 KB
/
update.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
<?php include 'header.php'; ?>
<div id="main-content">
<h2>Edit Record</h2>
<form class="post-form" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<div class="form-group">
<label>Id</label>
<input type="text" name="sid" />
</div>
<input class="submit" type="submit" name="showbtn" value="Show" />
</form>
<?php
if (isset($_SERVER['showbtn'])) {
$student_id = $_POST['sid'];
$student_name = $_POST['sname'];
$student_address = $_POST['saddress'];
$student_class = $_POST['sclass'];
$student_phone = $_POST['sphone'];
$connection = mysqli_connect("localhost", "root", "", "crud") or die("Couldn't connect'");
$query = "SELECT * FROM student WHERE sid={$student_id}";
$result = mysqli_query($connection, $query) or die("Data Send Failed");
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
?>
<form class="post-form" action="updatedata.php" method="post">
<div class="form-group">
<label for="">Name</label>
<input type="hidden" name="sid" value="<?php echo $row['sid'] ?>" />
<input type="text" name="sname" value="<?php echo $row['sname'] ?>" />
</div>
<div class="form-group">
<label>Address</label>
<input type="text" name="saddress" value="<?php echo $row['saddress'] ?>" />
</div>
<div class="form-group">
<label>Class</label>
<select name="sclass">
<option value="" selected disabled>Select Class</option>
<option value="1">BCA</option>
<option value="2">BSC</option>
<option value="3">B.TECH</option>
</select>
</div>
<div class="form-group">
<label>Phone</label>
<input type="text" name="sphone" value="<?php echo $row['sname'] ?>" />
</div>
<input class="submit" type="submit" value="Update" />
</form>
<?php
}
}
}
?>
</div>
</div>
</body>
</html>