카운트 관련질문
본문
$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]; <--- 이와 같이 하면 됩니다
?>
fetch_array 안에 fetch 가있을경우
array로 애들이 계속 루프돌면서 쭉쭉 나가는데
그안에 fetch 는 가만히 있지 안죠 같이 루프돌꺼에요
$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']}'
$result = sql_query($CHK);
while ($row = sql_fetch_array($result)){
echo $row[0];
}
열락처를 쪽지로보네세요 봐드릴게요
sql_fetch_array 안에 있어서 array 로 찍히는것입니다~~
array 밖으로 빼세요~