Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- jsp
- autoset
- Oracle
- NCS
- 원형그래프
- 버추얼머신
- 데이터베이스
- sql
- 정보처리기사
- Cisco
- rinux
- w3school
- 참조타입
- jsp연결
- javaee
- VLAN
- Java
- 네트워크관리사
- ciscopacket
- ospf
- 리눅스
- 네트워크
- html
- 정처기필기
- 자바
- cisco packet
- 오라클
- php
- 이것이 자바다
- 라우터
Archives
- Today
- Total
기록해! 정리해!
HTML -- 학생 성적처리 ver 11 코드정리 본문
2022.06.17 - [Visual studio] - HTML --학생 성적처리 ver 11 (폼태그, 자바스크립트,오토셋)
º index.php
<? include "top.php" ?>
<section>
<br><br>
<div align=center>
<font size=4> <b> 고등학교 성적처리 프로그램 </b> </font>
</div>
<div>
<br>
  1. 학생 성적 정보 테이블을 생성한다. <br>
  2. 학생 성적 테이블에 샘플데이터를 SQL 문을 이용하여 추가한다. <br>
  3. 주어진 화면 디자인을 이용하여 화면을 디자인한다. <br>
  4. 업무 여건에 따라 프로그램을 작성한다. <br>
</div>
<br>
</section>
<? include "bottom.php>
º top.php
<html>
<head>
<style>
header{
background-color:blue; /*바탕 색깔*/
height:60px; /*영역의 높이*/
line-height:60px; /*한글자의 높이*/
color:#ffffff; /*글자색깔*/
font-size:28px; /*글자 크기*/
text-align:center; /*가운데 정렬*/
}
nav{
background-color:#6699ff;
height:25px;
line-height:25px;
font-size:12px;
}
section{
background-color:#cccccc;
min-height:550px;
}
footer{
background-color:#3333ff;
height:30px;
line-height:30px;
text-align:center;
font-size:14px;
}
#body{
width:90%;
margin:auto;
}
</style>
</head>
<body>
<div id="body">
<header>
학생 성적처리 프로그램 Ver.1.11
</header>
<nav>
   
<a href=form.php>학생등록</a> 
<a href=list.php>학생목록/수정</a> 
<a href=index.php>홈으로</a>
</nav>
º bottom.php
<footer>
HRDKOREA Copyrightⓒ2022 ALL rights resources Development Service of Korea
</footer>
</div>
</body>
</html>
º edit.php
<? include "top.php" ?>
<?
$servername = "localhost" ;
$username = "root";
$password ="autoset";
$dbname="korea";
$conn = new mysqli($servername, $username, $password, $dbname );
?>
<?
$sno = $_REQUEST['sno'];
$SQL = "select * from examtbl where sno= $sno" ;
$result = $conn -> query($SQL);
$row = $result -> fetch_assoc();
$sno = $row['sno'];
$sname = $row['sname'];
$kor = $row['kor'];
$eng = $row['eng'];
$math = $row['math'];
$hist = $row['hist'];
?>
<script>
function ck1(){
if(f1.sno.value==""){
alert("학번을 입력해주세요");
f1.sno.focus();
return false;
}else if(f1.sname.value.length <= 2){
alert("이름을 3자 이상 입력해주세요");
f1.sname.value==""
f1.sname.focus();
return false;
}else{
alert("성적 입력이 완료되었습니다");
}
}
</script>
<section>
<br><br>
<div align=center>
<font size=4> <b> 성적 수정 하기 </b> </font>
</div>
<div>
<br>
<form name=f1 onSubmit="return ck1()"
method=get
action="update_ok.php">
<table border="1" align=center>
<tr><td>학번</td><td><input type=text name=sno value="<?=$sno?>"></td></tr>
<tr><td>성명</td><td><input type=text name=sname value="<?=$sname?>"></td></tr>
<tr><td>국어</td><td><input type=text name=kor value="<?=$kor?>"></td></tr>
<tr><td>영어</td><td><input type=text name=eng value="<?=$eng?>"></td></tr>
<tr><td>수학</td><td><input type=text name=math value="<?=$math?>"></td></tr>
<tr><td>역사</td><td><input type=text name=hist value="<?=$hist?>"></td></tr>
<tr><td colspan="2" align="center">
<input type=submit value="성적 수정">
</td></tr>
</table>
</form>
</div>
<br>
</section>
<? include "bottom.php" ?>
º form.php
<? include "top.php" ?>
<script>
function ck1(){
if(f1.sno.value==""){
alert("학번을 입력해주세요");
f1.sno.focus();
return false;
}else if(f1.sname.value.length <= 2){
alert("이름을 3자 이상 입력해주세요");
f1.sname.value==""
f1.sname.focus();
return false;
}else{
alert("성적 입력이 완료되었습니다");
}
}
</script>
<section>
<br><br>
<div align=center>
<font size=4> <b> 성적 입력 하기 </b> </font>
</div>
<div>
<br>
<form name=f1 onSubmit="return ck1()"
method=get
action="form_ok.php">
<table border="1" align=center>
<tr><td>학번</td><td><input type=text name=sno></td></tr>
<tr><td>성명</td><td><input type=text name=sname></td></tr>
<tr><td>국어</td><td><input type=text name=kor></td></tr>
<tr><td>영어</td><td><input type=text name=eng></td></tr>
<tr><td>수학</td><td><input type=text name=math></td></tr>
<tr><td>역사</td><td><input type=text name=hist></td></tr>
<tr><td colspan="2" align="center">
<input type=submit value="성적저장">
</td></tr>
</table>
</form>
</div>
<br>
</section>
<? include "bottom.php" ?>
º form_ok.php
<?
$servername = "localhost";
$username = "root";
$password = "autoset";
$dbname = "korea";
$conn = new mysqli($servername, $username, $password, $dbname);
?>
<?
$sno = $_GET['sno'];
$sname = $_GET['sname'];
$kor = $_GET['kor'];
$eng = $_GET['eng'];
$math = $_GET['math'];
$hist = $_GET['hist'];
$SQL = "insert into examtbl
values ('$sno','$sname','$kor','$eng','$math','$hist')";
echo $SQL;
$conn -> query($SQL);
?>
º list.php
<? include "top.php" ?>
<?
$servername = "localhost" ;
$username = "root";
$password ="autoset";
$dbname="korea";
$conn = new mysqli($servername, $username, $password, $dbname );
?>
<?
$SQL = "select * from examtbl order by sno desc" ;
$result = $conn -> query($SQL);
?>
<style>
#tr1{
background-color:#ffaaaa;
}
#tr2{
background-color:#aaaaff;
}
tr{
text-align:center;
}
</style>
<section>
<br><br>
<div align=center> <font size=4> <b> 성적 목록 보기 </b></font> </div>
<div align=center>
<br>
<table border=1>
<tr> <th> 순번 </th> <th> 학년 </th> <th> 반 </th><th> 번호 </th>
<th> 이름 </th> <th> 국어 </th>
<th> 영어 </th> <th> 수학 </th> <th> 역사 </th>
<th> 합계 </th> <th> 평균 </th> <th> 평점 </th>
</tr>
<?
$sum = 0; $avg = 0.0 ; $i =1 ;
$skor=0; $seng=0 ; $smath=0; $shist=0;
$ssum=0 ; $savg=0;
$askor=0; $aseng=0 ; $asmath=0; $ashist=0;
$assum=0 ; $asavg=0;
while( $row = $result -> fetch_assoc()) {
if ($i %2 == 1) {
$bg = 'tr1' ;
} else{
$bg = 'tr2' ;
}
$sum = $row['kor'] + $row['eng'] + $row['math']+ $row['hist'];
$avg = round( $sum / 4 , 1) ;
$skor = $skor + $row['kor'];
$seng = $seng + $row['eng'];
$smath = $smath+ $row['math'];
$shist = $shist + $row['hist'];
$ssum = $ssum + $sum;
$savg = $savg + $avg ;
$askor = round($skor / $i ,2);
$aseng = round($seng / $i ,2);
$asmath = round($smath / $i ,2);
$ashist = round($shist / $i ,2);
$assum = round($ssum / $i ,2);
$asavg = round($savg / $i ,2);
if ($avg >= 90){
$G ='A' ;
} else if ($avg >= 80) {
$G ='B' ;
} else if ($avg >= 70){
$G ='C' ;
} else {
$G ='F' ;
}
?>
<tr id="<?=$bg?>" >
<td> A<?=$i?> </td>
<td> <?=substr($row['sno'],0,1)?> </td>
<td> <?=substr($row['sno'],1,2)?> </td>
<td> <?=substr($row['sno'],3,2)?> </td>
<td>
<a href="edit.php?sno=<?=$row['sno']?>">
<?=$row['sname']?> </a>
</td>
<td><?=$row['kor']?> </td> <td><?=$row['eng']?> </td><td> <?=$row['math']?></td>
<td><?=$row['hist']?> </td>
<td><?=$sum?> </td>
<td><?=$avg?> </td>
<td><?=$G?> </td>
</tr>
<?
$i = $i + 1 ;
}
?>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> 총점 </td>
<td><?=$skor?> </td> <td><?=$seng?> </td>
<td><?=$smath?></td> <td><?=$shist?> </td>
<td><?=$ssum?> </td> <td><?=$savg?> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> 총 평균 </td>
<td><?=$askor?> </td> <td><?=$aseng?> </td>
<td><?=$asmath?></td> <td><?=$ashist?> </td>
<td><?=$assum?> </td> <td><?=$asavg?> </td>
<td> </td>
</tr>
</table>
</div>
<br>
</section>
<? include "bottom.php" ?>
º update_ok.php
<?
$servername = "localhost";
$username = "root";
$password = "autoset";
$dbname = "korea";
$conn = new mysqli($servername, $username, $password, $dbname);
?>
<?
$sno = $_GET['sno'];
$sname = $_GET['sname'];
$kor = $_GET['kor'];
$eng = $_GET['eng'];
$math = $_GET['math'];
$hist = $_GET['hist'];
$SQL = "update examtbl set sname='$sname', kor='$kor', eng='$eng', math='$math',hist='$hist'";
$SQL = $SQL . "where sno= '$sno'";
echo $SQL;
$conn -> query($SQL);
?>
<script>
location.href="list.php";
</script>
'Visual studio (PHP)' 카테고리의 다른 글
HTML -- 성적조회 프로그램 Ver1.0 (1) 코드정리 (0) | 2022.06.21 |
---|---|
HTML -- 성적조회 프로그램 Ver1.0 (1) (0) | 2022.06.20 |
HTML --폼 태그 (0) | 2022.06.17 |
HTML --학생 성적처리 ver 11 (폼태그, 자바스크립트,오토셋) (0) | 2022.06.17 |
JAVA Script (0) | 2022.06.16 |
Comments