<?php $conn = mysql_connect("hostname", "mysql_user_id", "mysql_user_password"); if (!$conn) { die("mysql_create() error"); } mysql_select_db("dbname"); mysql_close($conn); ?>
2) DB 테이블 내용 조회:
<?php $conn = mysql_connect("hostname", "mysql_user_id", "mysql_user_password"); if (!$conn) { die("mysql_create() error"); } mysql_select_db("dbname"); $query = "select * from 'tablename'"; $result = mysql_query($query); if (!$result) { die("mysql_query() error"); } while ($row = mysql_fetch_assoc($result)) { // handle row } mysql_free_result($result); mysql_close($conn); ?>팁) 페이징 처리
select * from 'tablename' limit <start index>, <view count>
3) 간단 조회:
<?php $conn = mysql_connect("hostname", "mysql_user_id", "mysql_user_password"); if (!$conn) { die("mysql_create() error"); } mysql_select_db("dbname"); $query = "select count(*) from 'tablename'"; $result = mysql_query($query); if (!$result) { die("mysql_query() error"); } $count = mysql_result($result, 0, 0); mysql_free_result($result); mysql_close($conn); ?>
댓글 없음:
댓글 쓰기