728x90
728x90
BIG
<div align ="center">
<br><br>
<h1>학생 성적 입력 </h1>
<? include("dbconn.php"); ?>
<!-- 불러오기-->
<?php
$sno=$_REQUEST['sno'];
$sql = "SELECT sno, sname, kor, eng, math, hist,kor+eng+math+hist as summ, (kor+eng+math+hist)/4 as avg
FROM examtbl WHERE sno=$sno";
$result = $conn->query($sql);
$row = $result ->fetch_assoc(); //레코드를 사용하겠습니다.
?>
<form align="center" action="update_ok.php" alt="폼오케" method=get>
학번: <input type ="text" name = "sno" value="<?=$row['sno']?>" ><br>
이름:<input type ="text" name = "sname"value="<?=$row['sname']?>><br>
국어:<input type ="text" name = "kor" value="<?=$row['kor']?>><br>
영어:<input type ="text" name = "eng" value="<?=$row['eng']?>><br>
수학:<input type ="text" name = "math"value="<?=$row['math']?>><br>
역사:<input type ="text" name = "hist"value="<?=$row['hist']?>><br>
<input type ="submit" value = "수정하기">
</form>
</div>
<?
$conn->close();
?>
<div align = "center">
<? include ("dbconn.php");?>
<?php
$sno=$_REQUEST['sno'];
$sname=$_REQUEST['sname'];
$kor=$_REQUEST['kor'];
$eng=$_REQUEST['eng'];
$math=$_REQUEST['math'];
$hist=$_REQUEST['hist'];
$sql = "update examtbl set sname='$sname', kor='$kor', eng='$eng', math='$math',
hist='$hist' where sno='$sno'";
if ($conn->query($sql) === TRUE) {
echo "저장완료";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
header('Location:list.php');
?>
</div>
728x90
반응형
BIG
'🍓PHP' 카테고리의 다른 글
[PHP] 게시판(페이지나누기, 검색기능) (0) | 2022.12.09 |
---|---|
[PHP/VSCode] 자동정렬 (0) | 2022.12.01 |
[PHP] 학생 성적 입력 테이블 만들기(mysql) (0) | 2022.11.30 |
[PHP] mysql 디비 넣어보기 (0) | 2022.11.30 |
[PHP]FOR문으로 테이블만들어보기! (0) | 2022.11.30 |
댓글