-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.php
69 lines (63 loc) · 2.23 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
63
64
65
66
67
68
69
<?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($_POST['showbtn'])){
$conn=mysqli_connect("localhost","root","","crud") or die("connection failed") ;
$stu_id=$_POST['sid'];
$sql="select *from student where sid={$stu_id}";
$result=mysqli_query($conn,$sql) or die("query unsucessfull");
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>
<?php
$sql1= "select *from studentclass";
$result1=mysqli_query($conn,$sql1) or die("query unsucessfull");
if(mysqli_num_rows($result1)>0){
echo '<select name="sclass">';
while($row1=mysqli_fetch_assoc($result1)){
if ($row['sclass']==$row1['cid']){
$select="selected";
}else{
$select="";
}
echo "<option {$select} value='{$row1['cid']}'>{$row1['cname']}</option>";
}
echo "</select>" ;
}
?>
</div>
<div class="form-group">
<label>Phone</label>
<input type="text" name="sphone" value="<?php echo $row['sphone']; ?> " />
</div>
<input class="submit" type="submit" value="Update" />
</form>
<?php
}
}
}
?>
</div>
</div>
</body>
</html>