2016-10-08 4 views
-1

PHP로 새롭고 웹 사이트 보안을 강화하기 위해 PDO를 사용하고 있지만 fetchcolumn()을 사용하면 while 루프가 제대로 작동하지 않습니다. 모든 행을 반환하지 않습니다. 여기 사용 후 fetchcolumn() while 루프가 pdo에서 올바르게 작동하지 않습니다.

$stmt = $pdo->prepare("SELECT * FROM impdate where joblink=? and status='y' order by id desc"); 
if ($stmt->execute(array($joblink))) { 
    $rows = $stmt->fetchColumn(); 
    if ($rows == "") { 
    echo '<style type="text/css">.impdate{display: none;}</style>'; 
    }else{ 
     while ($row = $stmt->fetch()) { 
      echo'<tr><td>'.$row['title'].'</td> <td>'.$row['date'].'</td></tr>'; 
     } 
    } 
} 

도움이 저를 제발 .....

내 코드입니다 : 내가 fetchcolumnl 제거 만 실행하면 루프 동안 다음이 제대로

+0

사용 $ rows = $ stmt-> rowCount(); 대신에 $ rows = $ stmt-> fetchColumn(); – JYoThI

+0

고마워, 그게 내게 도움이된다면 고맙다. –

+0

내 대답이 유용하다면 녹색으로 표시한다. 미래의 사용자에게 유용한 @Smart 개발자 – JYoThI

답변

0

시도를 작동 이

use $rows = $stmt->rowCount(); instead of $rows = $stmt->fetchColumn(); 

$ rows = $ stmt-> f etchColumn(); 단일 행만 가져 오는 데 사용됩니다.

관련 문제