Presentation is loading. Please wait.

Presentation is loading. Please wait.

DB연동하기 원격db접속.

Similar presentations


Presentation on theme: "DB연동하기 원격db접속."— Presentation transcript:

1 DB연동하기 원격db접속

2 DB 연동 DataAdapter Dataset 4. php와 mysql을 사용하여 웹페이지 제작 & 웹서버와 연동
1. 서버 접속 2. DB 접속 DB DB DB 3. 테이블 생성 *ftp로 서버에 업로드

3 1.서버 접속 TELNET 를 이용한 원격접속 시작 -> 실행 -> cmd입력
telnet comedu.mokwon.ac.kr login : 발급받은 계정 Password : 계정 비밀번호 계정 조원 p1 하현우, 유장훈 p2 송득부, 이현경, 김준동, 윤나래 p3 이권희, 홍현표, 임교희 p4 서진원, 성인애, 박진수 p5 조진욱, 장일해, 이희수

4 1.서버 접속(예제)

5 2.DB 접속 MYSQL 데이터베이스접속 데이터 베이스 선택 mysql -u 계정명 –p Enter password :
Use 계정명;

6 2.DB 접속(예제)

7 3.테이블 생성 create table `goods` ( `no` int(2) NOT NULL,
`name` char(20) default NULL, `price` int(7) default NULL, PRIMARY KEY (`no`) );

8 3.테이블 생성(예제) 생성된 테이블 보기 생성된 테이블 내용 보기

9 데이터 삽입 insert into goods(no,name,price) values('1','냉장고','10000');
insert into goods(no,name,price) values('2','TV','20000'); insert into goods(no,name,price) values('3','에어컨','30000'); insert into goods(no,name,price) values('4','냉장고','15000');

10 데이터 검색 select * from goods where name = '냉장고';
이름이 냉장고인 목록검색 select *from goods where no= ' 1 '; no 값이 1인 내용검색 select *from goods limit 10; 처음부터 10개만 검색

11 데이터 갱신 update goods set name= '라디오' where no= '1';
키 값이 1인 데이터의 이름을 라디오로 변경 update goods set name= '전자렌지' Where name= '냉장고'; 이름이 냉장고인 데이터의 이름을 전자렌지로 변경

12 데이터 삭제 delete from goods where no='1';
키 값이 1인 데이터를 삭제 delete from goods where name='냉장고'; 이름이 냉장고인 데이터를 삭제

13 DB연동하기 웹서버와의 연동

14 실습 예제 dbmain.html dbinsert.html dbinsert.php dbselect.html
dbselect.php dbupdate.html dbupdate.php dbdelete.html dbdelete.php dbshow_all.php

15 4.웹 서버와 연동(web서버접속) editplus 를 이용한 원격접속 포털 사이트에서 editplus 평가판 다운
파일->ftp->ftp 설정 [추가] 설명: 이름 ftp서버: comedu.mokwon.ac.kr username : 계정 Password : 계정 비밀번호

16 4.웹 서버와 연동(web서버접속)

17 4.웹 서버와 연동(파일생성) 자신의 조 폴더생성 파일생성 경 로 : /home/계정명/public_html/
웹 주소 : 계정/ 파일생성 dbmain.html dbinsert.html, dbinsert.php dbdelete.html, dbdelete.php dbupdate.html, dbupdate.php dbselect.html, dbselect.php dbshow_all.php

18 4.웹 서버와 연동(파일생성,dbmain.html)
<body> <center> <hr><h2>상품 DB관리</h2><hr> <p> <form action=" <input type="submit" value="입력하기"> </form> <p> <form action=" <input type="submit" value="검색하기"> <form action=" <input type="submit" value="수정하기"> <form action=" <input type="submit" value="삭제하기"> <form action=" <input type="submit" value="전체보기"> </form> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) ~p1

19 4.웹 서버와 연동(파일생성,dbmain.html)

20 4.웹 서버와 연동(파일생성,dbinsert.html)
<body> <center> <h2>상품정보를 입력하세요</h2> <p><hr> <form method=post action=" <table> <tr> <td>번호 : </td> <td><input type=text name=no size=2></td> </tr> <tr> <td>이름 : </td> <td><input type=text name=name size=20></td> </tr> <tr> <td>가격</td> <td><input type=text name=price size=7></td> <tr> <td colspan=2> <input type=submit value=확인> <input type=reset value=취소></td> </tr> </table> </form> <p><hr> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) ~p1

21 4.웹 서버와 연동(파일생성,dbinsert.php)
<html> <body> <center> <h2>상품정보추가</h2><hr> <? $connect = mysql_connect("comedu.mokwon.ac.kr", "psample", "psample"); mysql_select_db("psample", $connect); $query = "insert into goods(no, name, price) values('$no', '$name', '$price')"; mysql_query($query, $connect); mysql_close($connect); echo("<p>입력한 상품 정보가 DB에 추가 되었습니다.!<p>"); ?> <hr><p> <form action="dbmain.html"> <input type="submit" value="메인화면"> </form> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) p1 안의 내용은 계정 비밀번호를 적는다 ex) psample 안의 내용은 자신의 조 계정을 적는다 ex) p1

22 4.웹 서버와 연동(파일생성,dbdelete.html)
<body> <center> <h2>삭제할 상품 번호를 입력하세요</h2><p><hr> <form method=post action=" <table> <tr><td>번호 : </td> <td><input type=text name=no size=2></td></tr> <tr><td colspan=2> <input type=submit value=확인> <input type=reset value=취소></td></tr> </table> </form> <p><hr> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) ~p1

23 4.웹 서버와 연동(파일생성,dbdelete.php)
<html> <body> <center><h2>상품정보 삭제</h2><hr> <? $connect = mysql_connect("comedu.mokwon.ac.kr", "psample", "psample"); mysql_select_db("psample", $connect); $query="delete from goods where no='$no'"; mysql_query($query, $connect); echo("<p> 선택한 상품 정보가 DB에서 삭제되었습니다.<p>"); mysql_close($connect); ?> <hr></p> <form action="dbmain.html"> <input type="submit" value="메인화면"> </form> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) p1 안의 내용은 계정 비밀번호를 적는다 ex) psample 안의 내용은 자신의 조 계정을 적는다 ex) p1

24 4.웹 서버와 연동(파일생성,dbupdate.html)
<html> <body> <center> <h2>수정 정보를 입력하세요</h2><p><hr> <form method = post action=" <table> <tr><td>번호 : </td> <td><input type=text name=no size=2></td> </tr> <tr><td>이름 : </td> <td><input type=text name=name size=20></td></tr> <tr><td>가격 : </td><td><input type=text name=price size=8></td></tr> <tr><td colspan=2> <input type=submit value=확인> <input type=reset value=취소> </td></tr> </table> </form><p></hr> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) ~p1

25 4.웹 서버와 연동(파일생성,dbupdate.php)
<html> <body> <center><h2>상품 정보 수정</h2><hr> <? $connect = mysql_connect("comedu.mokwon.ac.kr", "psample", "psample"); mysql_select_db("psample", $connect); $query = "update goods set name='$name', price='$price' where no='$no'"; mysql_query($query, $connect); echo("<p>DB상품 정보가 수정되었습니다.!<p>"); mysql_close($connect); ?> <hr><p> <form action="dbmain.html"> <input type="submit" value="메인화면"> </form> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) p1 안의 내용은 계정 비밀번호를 적는다 ex) psample 안의 내용은 자신의 조 계정을 적는다 ex) p1

26 4.웹 서버와 연동(파일생성,dbselect.html)
<html> <body> <center> <h2>검색할 상품 번호를 입력</h2><p><hr> <form method=post action=" <table> <tr><td>번호:</td> <td><input type=text name=no size=2></td> </tr> <tr><td colspan=2> <input type=submit value=확인> <input type=reset value=취소> </td></tr> </table> </form> <p><hr> </center> </body> </html> 안의 내용은 자신의 조 계정을 적는다 ex) ~p1

27 4.웹 서버와 연동(파일생성,dbselect.php)
<html> <body> <center><h3>검색한 상품 정보</h3><hr> <? $connect = mysql_connect("comedu.mokwon.ac.kr", "psample", "psample"); mysql_select_db("psample", $connect); $query="select * from goods where no='$no'"; $result=mysql_query($query, $connect); ?> <table width=500><tr bgcolor="yellow"><th>번호</th><th>이름</th><th>가격</th></tr> while($row = mysql_fetch_array($result)){ <tr><td align=center><?= $row[no] ?></td> <td align=center><?= $row[name] ?></td> <td align=center><?= $row[price] ?></td> </tr> <? } ?> </table> 안의 내용은 자신의 조 계정을 적는다 ex) p1 안의 내용은 계정 비밀번호를 적는다 ex) psample 안의 내용은 자신의 조 계정을 적는다 ex) p1

28 4.웹 서버와 연동(파일생성,dbselect.php)
<? mysql_close($connect); ?> <hr> <p> <form action="dbmain.html"> <input type="submit" value="메인화면"> </form> </center> </body> </html>

29 4.웹 서버와 연동(파일생성,dbshow_all.php)
<html> <body> <center><h3>검색한 상품 정보</h3><hr> <? $connect = mysql_connect("comedu.mokwon.ac.kr", "psample", "psample"); mysql_select_db("psample", $connect); $query="select * from goods"; $result=mysql_query($query, $connect); ?> <table width="500“><tr bgcolor="yellow“><th>번호</th><th>이름</th><th>가격</th></tr> while($row = mysql_fetch_array($result)){ <tr><td align=center><?= $row[no] ?></td> <td align=center><?= $row[name] ?></td> <td align=center><?= $row[price] ?></td> </tr> <? } ?> </table> 안의 내용은 자신의 조 계정을 적는다 ex) p1 안의 내용은 계정 비밀번호를 적는다 ex) psample 안의 내용은 자신의 조 계정을 적는다 ex) p1

30 4.웹 서버와 연동(파일생성,dbshow_all.php)
<? mysql_close($connect); ?> <hr><p> <form action="dbmain.html"> <input type="submit" value="메인화면"> </form> </center> </body> </html>

31 4.웹 서버와 연동(예제)

32 5. ftp로 업로드

33 5. ftp로 업로드

34 5. ftp로 업로드


Download ppt "DB연동하기 원격db접속."

Similar presentations


Ads by Google