본문 바로가기
🍓PHP

[PHP] 게시판 수정하기

by 김말자 2022. 11. 30.
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

댓글