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
- Cisco
- Java
- javaee
- Oracle
- 네트워크
- 원형그래프
- 데이터베이스
- jsp연결
- 정보처리기사
- w3school
- 정처기필기
- autoset
- NCS
- 이것이 자바다
- ciscopacket
- VLAN
- sql
- 리눅스
- 자바
- php
- 버추얼머신
- 오라클
- 참조타입
- ospf
- 네트워크관리사
- cisco packet
- 라우터
- html
- jsp
- rinux
Archives
- Today
- Total
기록해! 정리해!
Autoset --학생 성적처리 ver 11 코드정리 본문
2022.06.10 - [Visual studio] - AutoSet -- SQL연결 학생 성적처리 ver 11
top.php
<link href="top.css" rel="stylesheet"
type="text/css" charset="UTF-8" />
<header> 학생 성적처리 Ver 11. </header>
<nav>
   <a href=form.php> 성적저장 </a>
 <a href=list.php> 성적조회 </a>
 <a href=index.php> 홈으로 </a>
</nav>
top.css
header{
background-color:#ADD8E6;
height:50px;
line-height:50px;
font-size:20px; color:#ffffff;
text-align:center;
}
nav{
background-color:#FFFACD;
height:30px;
line-height:30px;
font-size:13px; color:#ffffff;
}
section{
background-color:#F0FFFF;
font-size:12px; color:#696969;
min-heigt:500px;
}
footer{
background-color:#FFFACD;
height:40x;
line-height:20px;
font-size:14px; color:#C0C0C0;
text-align:center;
}
DBconn.php
<?
$servername = "localhost";
$username = "root";
$password = "autoset";
$dbname = "ppk400";
$conn = new mysqli($servername, $username, $password, $dbname);
?>
bottom.php
<footer>
<address>
<center>
Home page : http://www.visiongongjang.com <br>
mobile : 010-2222-3333 <br>
</center>
</address>
</footer>
list.php
<? include 'top.php' ?>
<? include 'DBconn.php' ?>
<style>
table{
width:600px;
}
</style>
<section>
<div align=center>
<br>
<h2> 학생 성적 목록 보기 </h2>
<?
$SQL = "select sno, sname, kor, eng, math, hist from examtbl " ;
$result = $conn -> query($SQL);
?>
<table border = 1 >
<tr>
<td>순번 </td>
<td>학번 </td> <td>이름 </td> <td>국어 </td> <td>영어 </td>
<td>수학 </td> <td>역사 </td> <td>합계 </td> <td>평균 </td>
<td>평점 </td>
</tr>
<?
$ksum =0 ;
$esum =0 ;
$msum =0 ;
$hsum =0 ;
$ssum =0 ;
$savg =0 ;
$count =0 ;
while ( $row = $result -> fetch_assoc() ){
$sum = $row['kor'] + $row['eng'] + $row['math'] + $row['hist'];
$avg = round($sum / 4,1) ;
$count = $count + 1 ;
$ksum = $ksum + $row['kor'];
$esum = $esum + $row['eng'];
$msum = $msum + $row['math'];
$hsum = $hsum + $row['hist'];
$ssum = $ssum + $sum;
$savg = $savg + $avg;
$kavg = round($ksum / $count, 1);
$eavg = round($esum / $count, 1);
$mavg = round($msum / $count, 1);
$havg = round($hsum / $count, 1);
$ssavg =round( $ssum / $count, 1);
$saavg = round($savg / $count, 1);
$bgcolor="#F0FFFF";
if ($avg >= 90 ){
$grade = "A" ;
} else if ($avg >= 80){
$grade = "B" ;
} else if ($avg >= 70){
$grade = "C" ;
} else {
$grade = "F" ;
$bgcolor="#778899";
}
?>
<tr bgcolor="<?=$bgcolor?>" >
<td><?=$count?></td>
<td>
<a href="edit.php?sno=<?=$row['sno']?>" >
<?=$row['sno']?>
</a>
</td>
<td><?=$row['sname']?></td>
<td><?=$row['kor']?></td> <td><?=$row['eng']?></td>
<td><?=$row['math']?></td> <td><?=$row['hist']?></td>
<td><?=$sum?></td>
<td>
<a href="del.php?sno=<?=$row['sno']?>">
<?=$avg?>
</td>
<td><?=$grade?></td>
</tr>
<?
}
?>
<tr>
<td colspan=3> 누적합 </td>
<td><?=$ksum?></td>
<td><?=$esum?></td>
<td><?=$msum?></td>
<td><?=$hsum?></td>
<td><?=$ssum?></td>
<td><?=$savg?></td>
<td></td>
</tr>
<tr>
<td colspan=3> 누적평균(<?=$count?>명) </td>
<td><?=$kavg?></td>
<td><?=$eavg?></td>
<td><?=$mavg?></td>
<td><?=$havg?></td>
<td><?=$ssavg?></td>
<td><?=$saavg?></td>
<td></td>
</tr>
</table>
</div>
<br>
</section>
<? include 'bottom.php' ?>
form.php
<? include 'top.php' ?>
<? include 'DBconn.php' ?>
<style>
table{
width:300px;
heigh:300px;
}
tr {
text-align:center;
}
</style>
<section>
<br>
<div align=center>
<h2> 학생 성적 입력 </h2>
<form action=form_ok.php>
<table border=1 >
<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
<? include 'DBconn.php' ?>
<?
$sno = $_GET['sno'];
$sname = $_GET['sname'];
$kor = $_GET['kor'];
$eng = $_GET['eng'];
$math = $_GET['math'];
$hist = $_GET['hist'];
$SQL = "insert into examtbl (sno, sname, kor, eng, math, hist)";
$SQL = $SQL . "values ('$sno', '$sname', '$kor', '$eng', '$math', '$hist')";
$conn->query($SQL);
?>
<script>
location.href="list.php";
</script>
index.php
<? include 'top.php' ?>
<? include 'DBconn.php' ?>
<section>
<br>
<div align=center>
<h2> 학생 성적 처리 프로그램 요약 </h2>
</div>
<br>
</section>
<? include 'bottom.php' ?>
edit.php
<? include 'top.php' ?>
<? include 'DBconn.php' ?>
<?
$sno =$_GET['sno'];
$SQL = "select sno, sname, kor, eng, math, hist 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'];
?>
<style>
table{
width:300px;
heigh:300px;
}
tr {
text-align:center;
}
</style>
<section>
<br>
<div align=center>
<h2> 학생 성적 수정 </h2>
<form action=update_ok.php>
<table border=1 >
<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' ?>
update_ok.php
<? include 'DBConn.php' ?>
<?
$sno =$_GET['sno'];
$sname=$_GET['sname'];
$kor=$_GET['kor'];
$eng=$_GET['eng'];
$math=$_GET['math'];
$hist=$_GET['hist'];
$SQL = "update examtbl set sname ='$sname' , ";
$SQL = $SQL . " kor ='$kor', ";
$SQL = $SQL . " eng ='$eng', ";
$SQL = $SQL . " math ='$math', ";
$SQL = $SQL . " hist ='$hist' where sno= '$sno' ";
// echo $SQL ;
$conn->query($SQL);
?>
<script>
location.href="list.php";
</script>
del.php
<? include 'DBconn.php' ?>
<?
$sno = $_GET['sno'];
$SQL = "delete from examtbl where sno= '$sno' ";
echo $SQL;
$conn->query($SQL);
?>
<script>
location.href="list.php";
</script>
form
list
index
'Visual studio (PHP)' 카테고리의 다른 글
JAVA Script (0) | 2022.06.16 |
---|---|
HTML 메모장 (0) | 2022.06.16 |
html 태그 (0) | 2022.06.15 |
Autoset --테이블 만들기 (0) | 2022.06.13 |
AutoSet -- SQL연결 학생 성적처리 ver 11 (0) | 2022.06.10 |
Comments