카운트 관련질문

카운트 관련질문

QA

카운트 관련질문

본문

$CHK = "select count(*) from {$g5['menu_table']}

 where length(me_code) = '4' and substring(me_code, 1, 2) = '{$row['me_code']}'

 order by me_order, me_id" 

 

$query = mysql_query($CHK); 

 

echo $query; 

 

하면 3, 0, 0 이 나와야하는데 

뭐 잘못한건가요?? 그누보드 함수 도통 쓰질몬하겠네요

이 질문에 댓글 쓰기 :

답변 7

<?php $query = sql_fetch($CHK);?>
<?php echo $query;?>

위처럼 행마다 php 열고 닫기를 하는 이유는 뭔가요?

 

<?php $query = sql_fetch($CHK);

 echo $query;<---이것의 값은 배열에 담긴 배열 변수이기 때문에 당연히 array가 됩니다

print_r($query);<---이렇게 해보면 알 수 있습니다

echo로 출력하기 위해서는 $CHK = "select count(*) as cnt 로 해놓고

echo  $query[cnt]; <--- 이와 같이 하면 됩니다

?>

 


 

    $sql .= " {$sql_order} limit {$from_record}, $page_rows ";

}

 

// 페이지의 공지개수가 목록수 보다 작을 때만 실행

if($page_rows > 0) {

    $result = sql_query($sql);

 

    $k = 0;

 

    while ($row = sql_fetch_array($result))

    {

$CHK = "select count(*) from {$g5['menu_table']} where length(me_code) = '4'
and substring(me_code, 1, 2) = '{$row['me_code']}'

<?php $query = sql_fetch($CHK);?>
<?php echo $query;?>

하면 3번 돌고 있으니까
3
0
0
이 되어여하는데
왜 array로 찍힐까요..

$CHK = "select count(*) from {$g5['menu_table']} where length(me_code) = '4' 
and substring(me_code, 1, 2) = '{$row['me_code']}'  

 

    $result = sql_query($CHK);

 

    while ($row = sql_fetch_array($result)){

echo $row[0];

}

sql_fetch_array 안에 있어서 array 로 찍히는것입니다~~

array 밖으로 빼세요~

답변을 작성하시기 전에 로그인 해주세요.
전체 0 | RSS
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT