Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Base Web Programming

Similar presentations


Presentation on theme: "Data Base Web Programming"— Presentation transcript:

1 Data Base Web Programming
PHP

2 접속하기 서버에 접속한다 DB접속하기 SSH Secure Shell 프로그램 이용 Host : et2.hknu.ac.kr
Id : t학번 Pwd : a <- 초기값 DB접속하기 mysql –uhk학번 -pa12345 hk학번 ex) mysql –uhk pa12345 hk

3 “mysql”에 접속한다. mysql –uhk pa hk

4 “addr_list.html” 수정 <?
$dbconn = mysql_connect("localhost",“hk ","a12345"); $status = mysql_select_db(“hke "); // DB명 = ID와 같음 if (!$status) { echo("DB_ERROR"); exit; } // 주소읽기 $sqry1 = " select * from addr "; $result = mysql_query($sqry1); $rows = mysql_num_rows($result); ?>

5 for($i = 1; $i <= $rows; $i++) {
<td><a href='./addr_view.html?seq=<?echo($row->seq)?>'><?echo($row->seq)?></a></td> 수정 <? for($i = 1; $i <= $rows; $i++) { $row = mysql_fetch_object($result); ?> <tr> <td><?echo($row->seq)?></td> <td><?echo($row->na)?></td> <td><?echo($row->hp)?></td> <td><?echo($row-> )?></td> </tr> } </table> <a href="./addr.html">주소 입력</a> </BODY> </HTML> <HTML> <HEAD> <TITLE>주소등록</TITLE> </HEAD> <BODY> <table border=1> <tr> <td>순번</td> <td>이름</td> <td>핸드폰</td> <td>이메일</td> </tr>

6 “addr_view.html” 신규입력 <? // ID PWD
$dbconn = mysql_connect("localhost",“hk ","a12345"); $status = mysql_select_db(“hk "); // DB명 = ID와 같음 if (!$status) { echo("DB_ERROR"); exit; } // 주소읽기 $sqry1 = " select * from addr where seq=$seq "; $result = mysql_query($sqry1); $row = mysql_fetch_object($result); ?>

7 <TITLE>주소상세보기</TITLE>
</HEAD> <BODY> <table border=1> <tr> <td>순번</td> <td><?echo($row->seq)?></td> </tr> <td>이름</td> <td><?echo($row->na)?></td> <td>핸드폰</td> <td><?echo($row->hp)?></td> <td>이메일</td> <td><?echo($row-> )?></td> <td>주소</td> <td><?echo($row->addr)?></td> </table> <a href="./addr.html">주소 입력</a><br> <a href="./addr_rewrite.html?seq=<?echo($row->seq)?>">주소 수정</a><br> <a href="./addr_list.html">주소 리스트</a> </BODY> </HTML>

8 “Web에서 확인한 경우” 클릭

9

10 “addr_rewrite.html” 작성하기
<? // ID PWD $dbconn = mysql_connect("localhost",“hk ","a12345"); $status = mysql_select_db(“hk "); // DB명 = ID와 같음 if (!$status) { echo("DB_ERROR"); exit; } // 주소읽기 $sqry1 = " select * from addr where seq=$seq "; $result = mysql_query($sqry1); $row = mysql_fetch_object($result); ?>

11 <HTML> <HEAD> <TITLE>주소등록</TITLE> </HEAD> <BODY> <Form method="post" action="addr_rewrite.php"> 이름 : <input type="text" name="na" size="10" value="<?echo($row->na)?>"><br> 핸드폰 : <input type="text" name="hp" size="20" value="<?echo($row->hp)?>"><br> 전화번호 : <input type="text" name="tel" size="20" value="<?echo($row->tel)?>"><br> 주소 : <input type="text" name="addr" size="50" value="<?echo($row->addr)?>"><br> 이메일 : <input type="text" name=" " size="30" value="<?echo($row-> )?>"><br> <input type="submit" value="전송"> <input type="reset" value="다시쓰기"> <input type="hidden" name="seq" value="<?echo($row->seq)?>"> </form> </BODY> </HTML>

12 “addr_rewrtie.php”작성 <? // ID PWD
$dbconn = mysql_connect("localhost","p12345","a12345"); $status = mysql_select_db("p12345"); // DB명 = ID와 같음 if (!$status) { echo("DB_ERROR"); exit; } $sqry = " update addr set na = '$na' , hp = '$hp', tel='$tel', addr='$addr', ='$ ' where seq=$seq "; $result=mysql_query($sqry); if (!$result) echo("update ERROR"); echo("저장 성공   "); echo("<a href='./addr.html'>다시 입력</a><br>"); echo("<a href='./addr_list.html'>목록보기</a>"); ?>

13 “WEB에서 확인” 클릭

14

15 리스트 보기에서 클릭하여 확인하기


Download ppt "Data Base Web Programming"

Similar presentations


Ads by Google