일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 윈도우 10 슬라이드 종료 단축키 만들기
- 작업표시줄 먹통현상 해결하기
- POP폰트
- javascript redirection code
- 잘라내기 단축키
- 엑셀에서 콤마를 제외한 숫자 개수 세기
- 오라클DB팁
- 한글 기호 자동변환 해제
- 바탕화면에 원격 데스크톱 연결 바로가기 만들기
- ie모드 해제
- 스타워즈 영화 감상 순서
- 부자의 그릇 요약
- 금리와 물가와의 상관관계
- 윈도우 10 프리징 해결하기
- 업무에 바로 쓰는 SQL
- 헤드퍼스트SQL
- OpenSSL 업데이트
- 붙여넣기 단축키
- 메타버스 용어
- AIX 버전확인
- AIX NAS NFS
- 롤오버 기간을 설정한 비밀번호 마이그레이션 방법
- 복사 단축키
- AIX NFS
- 무료 이미지 제공 사이트
- 오라클팁
- 윈도우10 먹통현상 해결하기
- 삼성멀티캠퍼스SQL
- net user 사용법
- 레드햇 버전확인
Archives
- Today
- Total
Today is Present.
[PHP] ajax와 mysql 연동하기 2 본문
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$q=$_GET["q"]; | |
$con = mysqli_connect('localhost','user_id','user_pwd','test_db'); | |
if (!$con) { | |
die('Could not connect: ' . mysqli_error($con)); | |
} | |
$sql = "SELECT * FROM persons WHERE user_name = '".$q."'"; | |
$result = mysqli_query($con,$sql); | |
echo "<table border='1'> | |
<tr> | |
<th>username</th> | |
<th>Age</th> | |
<th>Home</th> | |
<th>Job</th> | |
</tr>"; | |
while($row = mysqli_fetch_array($result)) | |
{ | |
echo "<tr>"; | |
echo "<td>" . $row['user_name'] . "</td>"; | |
echo "<td>" . $row['age'] . "</td>"; | |
echo "<td>" . $row['home'] . "</td>"; | |
echo "<td>" . $row['job'] . "</td>"; | |
echo "</tr>"; | |
} | |
echo "</table>"; | |
mysqli_close($con); | |
?> | |
// 출처: https://makand.tistory.com/entry/PHP-AJAX-데이터베이스-연동 [Park'S의 IT 이야기] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<script> | |
function showUser(str) | |
{ | |
if (str=="") | |
{ | |
document.getElementById("txtHint").innerHTML=""; | |
return; | |
} | |
if (window.XMLHttpRequest) { | |
// code for IE7+, Firefox, Chrome, Opera, Safari | |
xmlhttp=new XMLHttpRequest(); | |
} | |
else { | |
// code for IE6, IE5 | |
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); | |
} | |
xmlhttp.onreadystatechange=function() { | |
if (xmlhttp.readyState==4 && xmlhttp.status==200) { | |
document.getElementById("txtHint").innerHTML=xmlhttp.responseText; | |
} | |
} | |
xmlhttp.open("GET","ajax.php?q="+str,true); | |
xmlhttp.send(); | |
} | |
</script> | |
</head> | |
<body> | |
<form> | |
<select name="users" onchange="showUser(this.value)"> | |
<option value="">Select a person:</option> | |
<option value="park">park</option> | |
<option value="kim">kim</option> | |
<option value="song">song</option> | |
<option value="lee">lee</option> | |
</select> | |
</form> | |
<br> | |
<div id="txtHint"><b>사람들의 정보를 이곳에 보여줌.</b></div> | |
</body> | |
</html> | |
// 출처: https://makand.tistory.com/entry/PHP-AJAX-데이터베이스-연동 [Park'S의 IT 이야기] |
728x90
반응형
'프로그래밍, 코딩' 카테고리의 다른 글
처음 배우는 플러터 #유동환 (0) | 2023.05.22 |
---|---|
아이투자에서 종목 데이터 크롤링 후 종목분석 (0) | 2021.03.13 |
[javascript] 브라우저 버전 체크 (0) | 2021.02.09 |
[PHP4] 기준 시간 이후로 페이지 열기 (0) | 2021.02.08 |
[PHP] ajax와 mysql 연동하기 (0) | 2021.02.08 |