일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 자바
- w3school
- NCS
- 데이터베이스
- 참조타입
- 라우터
- Oracle
- 이것이 자바다
- jsp
- 리눅스
- php
- ospf
- 정보처리기사
- rinux
- 네트워크관리사
- Java
- 버추얼머신
- jsp연결
- 오라클
- sql
- html
- javaee
- 정처기필기
- VLAN
- 원형그래프
- 네트워크
- Cisco
- autoset
- ciscopacket
- cisco packet
- Today
- Total
기록해! 정리해!
HTML -- 투표 본문
06/30
1. 테이블 만들기
1)
Create table tbl_vote_202005(
v_jumin char(13) not null primary key,
v_name varchar(20),
m_no char(1),
v_time char(4),
v_area char(20),
v_confirm char(1)
);
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('99010110001','김유권','1','0930','제1투표장','N');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('89010120002','이유권','2','0930','제1투표장','N');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('69010110003','박유권','3','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('59010120004','홍유권','4','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('79010110005','조유권','5','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('89010120006','최유권','1','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('59010110007','지유권','1','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('49010120008','장유권','3','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('79010110009','정유권','3','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('89010120010','강유권','4','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('99010110011','신유권','5','0930','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('79010120012','오유권','1','1330','제1투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('69010110013','현유권','4','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('89010110014','왕유권','2','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('99010110015','유유권','3','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('79010110016','한유권','2','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('89010110017','문유권','4','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('99010110018','양유권','4','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('99010110019','구유권','4','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('79010110020','황유권','5','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('69010110021','배유권','3','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('79010110022','전유권','3','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('99010110023','고유권','1','1330','제2투표장','Y');
insert into tbl_vote_202005(v_jumin,v_name,m_no,v_time,v_area,v_confirm) values('59010110024','권유권','3','1330','제2투표장','Y');
2)
Create table tbl_member_202005(
m_no char(1) not null primary key,
m_name varchar(20),
p_code char(2),
p_school char(1),
m_jumin char(13),
m_city varchar(20)
);
insert into tbl_member_202005(m_no, m_name, p_code, p_school, m_jumin, m_city) values('1','김후보','P1','1','6603011999991','수선화동');
insert into tbl_member_202005(m_no, m_name, p_code, p_school, m_jumin, m_city) values('2','이후보','P2','3','5503011999992','민들래동');
insert into tbl_member_202005(m_no, m_name, p_code, p_school, m_jumin, m_city) values('3','박후보','P3','2','7703011999993','나팔꽃동');
insert into tbl_member_202005(m_no, m_name, p_code, p_school, m_jumin, m_city) values('4','조후보','P4','2','8803011999994','진달래동');
insert into tbl_member_202005(m_no, m_name, p_code, p_school, m_jumin, m_city) values('5','최후보','P5','3','9903011999995','개나리동');
3)
Create table tbl_party_202005(
p_code char(2) not null primary key,
p_name varchar(20),
p_indate date,
p_reader varchar(20),
p_tel1 char(3),
p_tel2 char(4),
p_tel3 char(4)
);
insert into tbl_party_202005 (p_code,p_name,p_indate,p_reader,p_tel1,p_tel2,p_tel3) values ('P1','A정당','2010-01-01','위대표','02','1111','0001');
insert into tbl_party_202005 (p_code,p_name,p_indate,p_reader,p_tel1,p_tel2,p_tel3) values ('P2','B정당','2010-02-01','명대표','02','1111','0002');
insert into tbl_party_202005 (p_code,p_name,p_indate,p_reader,p_tel1,p_tel2,p_tel3) values ('P3','C정당','2010-03-01','기대표','02','1111','0003');
insert into tbl_party_202005 (p_code,p_name,p_indate,p_reader,p_tel1,p_tel2,p_tel3) values ('P4','D정당','2010-04-01','옥대표','02','1111','0004');
insert into tbl_party_202005 (p_code,p_name,p_indate,p_reader,p_tel1,p_tel2,p_tel3) values ('P5','E정당','2010-05-01','임대표','02','1111','0005');
2. index.php / top.php / bottom.php 만들기
index.php
<? include "top.php"?>
<section>
<br><br>
<div align=center><font size=4>
<h1> 과정평가형 자격 CBQ </h1>
</div>
<div>
<h3>  무언가의 내용이 들어있음.</h3>
<br>  내용1. 직접투표 : 선거권자가 대리인을 거치지 않고 자신이 직접투표
<br>  내용2. 비밀투표 : 기표소에 들어가 투표자 이외에는 누구에게 투표했는지 알 수 없게 하는 제도
<br>  내용3. 보통선거 : 만 19세 이상 국민은 성별, 재산, 종교, 교육에 관계없이 선거권을 주는 제도
<br>  내용4. 평등선거 : 모든 유권자에게 한 표씩 주고, 그 한표의 가치를 평등하게 인정하는 제도
</div>
</section>
<? include "bottom.php"?>
top.php
<html>
<head>
<style>
header{
background-color:#0000ff;
height: 70px;
line-height: 70px;
color:#ffffff;
font-size:28px;
text-align:center;
}
nav{
background-color:#00aaff;
height: 30px;
line-height: 30px;
font-size:14px;
}
section{
background-color:#cccccc;
min-height:500px;
}
footer{
background-color:#00aaff;
height: 40px;
line-height: 40px;
font-size:16px;
color:#ffffff;
text-align:center;
}
#body{
width:90%
margin:auto;
}
a:link, a:visited{
color:#ffffff;
text-decoration: none;
}
</style>
</head>
<body>
<div id="body">
<header>(과정평가형 정보처리산업기사) 지역구의원투표 프로그램 Ver 2020-05</header>
<nav>
 <a href=member_list.php>후보조회</a>
 <a href=vote.php>투표하기</a>
 <a href=vote_list.php>투표검수조회</a>
 <a href=member_rank.php>후보자등수</a>
 <a href=index.php>홈으로</a>
</nav>
bottom.php
<footer>
HRDKOREA Copyrightⓒ2015 ALL rights Resources Development Services of Korea
</footer>
</div>
</body>
</html>
3. member_list.php (후보조회)
<? include "top.php"?>
<?
$conn = new mysqli("localhost","root","autoset","korea");
$SQL = "select m_no, m_name, p_name, p_school, m_jumin, m_city, p_tel1, p_tel2, p_tel3
from tbl_member_202005 m join tbl_party_202005 p
on m.p_code = p.p_code " ;
$result = $conn -> query($SQL);
?>
<style>
tr{
text-align:center;
}
</style>
<section>
<br>
<div align=center><font size=4>
<h1> 후 보 조 회 </h1>
</div>
<div align=center>
<table border=1 width=600 height=250>
<tr> <th>후보번호</th> <th>성명</th> <th>소속정당</th>
<th>학력</th> <th>주민번호</th> <th>지역구</th> <th>대표전화</th> </tr>
<?
while ($row = $result -> fetch_assoc()){
$m_jumin1 = substr($row['m_jumin'],0,6);
$m_jumin2 = substr($row['m_jumin'],6,7);
if($row['p_school'] =="1"){
$p_school = "고졸";
}else if($row['p_school'] =="2"){
$p_school = "학사";
}else if($row['p_school'] =="3"){
$p_school = "석사";
}else if($row['p_school'] =="4"){
$p_school = "박사";
}
?>
<tr>
<td><?=$row['m_no']?></td>
<td><?=$row['m_name']?></td>
<td><?=$row['p_name']?></td>
<td><?=$p_school?></td>
<td><?=$m_jumin1?>-<?=$m_jumin2?></td>
<td><?=$row['m_city']?></td>
<td><?=$row['p_tel1']?>-<?=$row['p_tel2']?>-<?=$row['p_tel3']?></td>
</tr>
<?
}
?>
</div>
</table>
</section>
<? include "bottom.php"?>
4. vote.php (투표하기)
<? include "top.php"?>
<script>
function ck1(){
alert ("확인");
return false;
}
</script>
<section>
<br><br>
<div align=center><font size=4>
<h1> 투 표 하 기 </h1>
</div>
<div align=center>
<form action=vote_ok.php onSubmit="return ck1()">
<table border=1 width=550 height=250>
<tr> <td>주민번호</td> <td><input type=text name=jumin size=20 > 예 : 8906153154726 </td> </tr>
<tr> <td>성명</td> <td><input type=text name=name size=10></td> </tr>
<tr> <td>투표번호</td>
<td><select name=no>
<option></option>
<option value=1>[1]김후보</option>
<option value=2>[2]이후보</option>
<option value=3>[3]박후보</option>
<option value=4>[4]조후보</option>
<option value=5>[5]최후보</option>
</select>
</td></tr>
<tr> <td>투표시간</td> <td><input type=text name=time size=10></td> </tr>
<tr> <td>투표장소</td> <td><input type=text name=area size=10></td> </tr>
<tr> <td>유권자확인</td>
<td><input type=radio name=confirm value="Y"> 확인
<input type=radio name=confirm value="N"> 미확인 </td> </tr>
<tr> <td colspan=2 align=center>
<input type=submit value="투표하기">
<input type=reset value="다시하기"></td></tr>
</table>
</form>
</div>
</section>
<? include "bottom.php"?>
하고 vote_ok.php 새파일 만들어주면
투표하기 눌러서
확인하면 vote_ok.php로 넘어간다
- 스크립트 추가하기 +포커스
<script>
function ck1(){
if(f1.jumin.value==""){
alert ("주민번호가 입력되지 않았습니다!");
f1.jumin.focus();
return false;
}else if(f1.name.value==""){
alert ("성명이 입력되지 않았습니다!");
f1.name.focus();
return false;
} else if(f1.no.value==""){
alert ("투표번호가 선택되지 않았습니다!");
f1.no.focus();
return false;
} else if(f1.time.value==""){
alert ("투표시간이 입력되지 않았습니다!");
f1.time.focus();
return false;
} else if(f1.area.value==""){
alert ("투표장소가 입력되지 않았습니다!");
f1.area.focus();
return false;
} else if(f1.confirm.value==""){
alert ("유권자확인이 선택되지 않았습니다!");
f1.confirm.focus();
return false;
}
}
</script>
.
.
.
<form name=f1 action=vote_ok.php onSubmit="return ck1()">
5. vote_ok.php
<? $conn = new mysqli("localhost","root","autoset","korea"); ?>
<?
$jumin = $_GET['jumin'];
$name = $_GET['name'];
$no = $_GET['no'];
$time = $_GET['time'];
$area = $_GET['area'];
$confirm = $_GET['confirm'];
$SQL = "insert into tbl_vote_202005 (v_jumin,v_name,m_no,v_time,v_area,v_confirm)
values ('$jumin', '$name', '$no', '$time', '$area', '$confirm' ) ";
$result = $conn->query($SQL);
if ($result == "1"){
?>
<script>
alert("투표하기 정보가 정상적으로 등록되었습니다.");
location.href="index.php" ;
</script>
<?
} else {
?>
<script>
alert("투표하기 정보가 등록되지 못하였습니다.");
location.href="vote.php" ;
</script>
<?
}
?>
6. vote_list.php
1) 주민번호로 생년월일 나타내기
$v_jumin1 = substr($row['v_jumin'],0,2);
$v_jumin2 = substr($row['v_jumin'],2,2);
$v_jumin3 = substr($row['v_jumin'],4,2);
<td>19<?=$v_jumin1?>년<?=$v_jumin2?>월<?=$v_jumin3?>일생</td>
2) 주민번호로 만 나이 나타내기
$birth_year = substr($row['v_jumin'],0,2);
$age = date("Y", time()) - (1900 + $birth_year);
<td>만<?=$age?>세</td>
3) 주민번호로 성별 나타내기
$sex = substr($row['v_jumin'],6,1);
if ($sex == 1) {
$sex = "여";}
else {
$sex = "남";
}
<td><?=$sex?></td>
4) 투표시간 : 넣어서 나타내기
$v_time1 = substr($row['v_time'],0,2);
$v_time2 = substr($row['v_time'],2,3);
<td><?=$v_time1?>:<?=$v_time2?></td>
5) 유권자확인 확인/미확인 으로 나타내기
if( $row['v_confirm'] == "Y"){
$confirm = "확인";
}else if($row['v_confirm'] == "N"){
$confirm = "미확인";
}
<td><?=$confirm?></td>
6) 전체 php
<? include "top.php"?>
<?
$conn = new mysqli("localhost","root","autoset","korea");
$SQL = "select v_jumin,v_name,m_no,v_time,v_area,v_confirm from tbl_vote_202005 " ;
$result = $conn -> query($SQL);
?>
<style>
tr{
text-align:center;
}
</style>
<section>
<br><br>
<div align=center><font size=4>
<h1> 투표 검수 조회 </h1>
</div>
<div align=center>
<table border=1 width=600>
<tr><td>성명</td><td>생년월일</td><td>나이</td>
<td>성별</td><td>투표번호</td><td>투표시간</td><td>유권자확인</td></tr>
<?
while ($row = $result -> fetch_assoc()){
$v_jumin1 = substr($row['v_jumin'],0,2);
$v_jumin2 = substr($row['v_jumin'],2,2);
$v_jumin3 = substr($row['v_jumin'],4,2);
$v_time1 = substr($row['v_time'],0,2);
$v_time2 = substr($row['v_time'],2,3);
if( $row['v_confirm'] == "Y"){
$confirm = "확인";
}else if($row['v_confirm'] == "N"){
$confirm = "미확인";
}
$birth_year = substr($row['v_jumin'],0,2);
$age = date("Y", time()) - (1900 + $birth_year);
$sex = substr($row['v_jumin'],6,1);
if ($sex == 1) {
$sex = "여";}
else {
$sex = "남";
}
?>
<tr>
<td><?=$row['v_name']?></td>
<td>19<?=$v_jumin1?>년<?=$v_jumin2?>월<?=$v_jumin3?>일생</td>
<td>만<?=$age?>세</td>
<td><?=$sex?></td>
<td><?=$row['m_no']?></td>
<td><?=$v_time1?>:<?=$v_time2?></td>
<td><?=$confirm?></td>
</tr>
<?
}
?>
</table>
</div>
<br><br>
</section>
<? include "bottom.php"?>
7. member_rank.php (후보자 등수)
<? include "top.php"?>
<?
$conn = new mysqli("localhost","root","autoset","korea");
$SQL = "select m.m_no, m_name, count(*) as total
from tbl_member_202005 m join tbl_vote_202005 v
on m.m_no = v.m_no
where v_confirm='Y'
group by m_no, m_name
order by count(v.m_no) desc " ;
$result = $conn -> query($SQL);
?>
<style>
tr{
text-align:center;
}
</style>
<section>
<br><br>
<div align=center><font size=4>
<h1> 후보자 등수 </h1>
</div>
<div align=center>
<table border=1 width=400>
<tr><td>후보번호</td><td>성명</td><td>총투표건수</td></tr>
<?
while ($row = $result -> fetch_assoc()){
?>
<tr>
<td><?=$row['m_no']?></td>
<td><?=$row['m_name']?></td>
<td><?=$row['total']?></td>
</tr>
<?
}
?>
</table>
</div>
</section>
<? include "bottom.php"?>
- 상위 10개 뽑아보기 (limit 안쓰고)
while ($row = $result -> fetch_assoc()){
$i ++ ;
$v_jumin1 = substr($row['v_jumin'],0,2);
$v_jumin2 = substr($row['v_jumin'],2,2);
$v_jumin3 = substr($row['v_jumin'],4,2);
$v_time1 = substr($row['v_time'],0,2);
$v_time2 = substr($row['v_time'],2,3);
if( $row['v_confirm'] == "Y"){
$confirm = "확인";
}else if($row['v_confirm'] == "N"){
$confirm = "미확인";
}
$birth_year = substr($row['v_jumin'],0,2);
$age = date("Y", time()) - (1900 + $birth_year);
$sex = substr($row['v_jumin'],6,1);
if ($sex == 1) {
$sex = "여";}
else {
$sex = "남";
}
if ($i <= 10 ){
?>
<tr>
<td><?=$i?></td>
- 성명으로 검색창 만들기
<?
$ch1 = $_GET['ch1'];
$ch2 = $_GET['ch2'];
if ($ch1 == "" ) {
$SQL = " select v_jumin,v_name,m_no, v_time,v_area,v_confirm
from tbl_vote_202005 order by v_time, v_confirm" ;
} else if($ch1 == "v_name") {
$SQL = " select v_jumin,v_name,m_no, v_time,v_area,v_confirm
from tbl_vote_202005 where v_name like '%$ch2%' order by v_time, v_confirm" ;
}
$conn = new mysqli("localhost","root","autoset","korea");
$result =$conn -> query($SQL);
?>
.
.
.
<form>
<select name=ch1>
<option value = "v_name" >성명</option>
</select>
<input type=text name=ch2>
<input type=submit value="검색하기">
</form>
'Visual studio (PHP)' 카테고리의 다른 글
HTML --그래프 , 홈쇼핑 코드정리 (0) | 2022.06.30 |
---|---|
HTML --홈쇼핑 테이블 (0) | 2022.06.29 |
HTML -- 그래프 (0) | 2022.06.29 |
HTML --페이지 나누기,로그인,로그아웃 코드정리 (0) | 2022.06.29 |
HTML -- 페이지 나누기 , 로그인 로그아웃 (0) | 2022.06.28 |