250x250
Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Oracle
- IntelliJ
- 스프링
- mariadb
- 스프링부트
- 이클립스
- log4j
- 인텔리제이
- Plugins
- log4j2
- #JVM
- #오라클
- #이클립스
- 플러그인
- #Oracle
- 소스코드 맵
- html
- Eclipse
- #java
- 설정
- #eclipse
- Spring
- 오라클
- #자바
- springboot
- CodeGlance
- #자바가상머신
- 환경설정
- 설치
- Like
Archives
- Today
- Total
커피와 개발자
[MySQL API] mysql_fetch_assoc() 본문
728x90
MySQL 질의 결과를 한 줄씩 배열 형태로 반환할 때,
associative array처럼 결과 줄(row)를 가져온다.
mysql_fetch_array()함수에서 둘째 인자만 없다면 똑같다.
【예제】
<html><body>
< ?
mysql_connect('localhost','root','root_password');
mysql_select_db("mydb");
$query= "select * from employees";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo $row["id"];
echo $row["name"];
echo "<br>";
}
mysql_free_result($result);
? >
</body></html>
associative array처럼 결과 줄(row)를 가져온다.
mysql_fetch_array()함수에서 둘째 인자만 없다면 똑같다.
【예제】
<html><body>
< ?
mysql_connect('localhost','root','root_password');
mysql_select_db("mydb");
$query= "select * from employees";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
echo $row["id"];
echo $row["name"];
echo "<br>";
}
mysql_free_result($result);
? >
</body></html>
728x90
'데이터베이스 > SQL' 카테고리의 다른 글
[MySQL API] mysql_field_flags() (0) | 2011.03.03 |
---|---|
[MySQL API] mysql_fetch_field() (0) | 2011.03.03 |
[MySQL API] mysql_fetch_array() (0) | 2011.03.03 |
[MySQL API] mysql_escape_string() (0) | 2011.03.03 |
[MySQL API] mysql_error() (0) | 2011.03.03 |
Comments