2011-02-09 7 views

답변

3

PHP: mysql_result

<?php 

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); 
if (!$link) { 
    die('Could not connect: ' . mysql_error()); 
} 
if (!mysql_select_db('database_name')) { 
    die('Could not select database: ' . mysql_error()); 
} 
$result = mysql_query('SELECT COUNT(*) FROM myTable'); 
if (!$result) { 
    die('Could not query:' . mysql_error()); 
} 
$rowCount = mysql_result($result, 0); // get the count 
echo $rowCount; // echo the count 

mysql_close($link); 
?> 

체크 아웃 PHP mysql functions에서 수정 (예를 들어 이름이 "TBL")을 테이블에 레코드의 수를 얻을 수 시작되었습니다. 어떤 종류의 프레임 워크를 사용한다면 해당 프레임 워크에 대한 데이터베이스 문서를 확인하십시오.

3

사용이 쿼리는

select count(*) as CountRecords from tbl 
관련 문제