1
PDO를 사용 중이고 테이블에 결과를 인쇄하려고하지만 값이 나타나지 않습니다. <td>
태그를 사용해야합니다. 여기 PDO가있는 테이블에 결과 인쇄
fetch()
의
fetchAll()
외부를 호출 할 필요가
<?php
require_once('config.php');
$stmt = $connect->prepare("SELECT id, username, email FROM user");
$stmt->execute();
$result = $stmt->fetch(PDO::FETCH_ASSOC);
?>
<table id="table">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>email</th>
</tr>
</thead>
<tbody>
<?php
foreach ($result as $row):
?>
<tr>
<td><?= $row['id'];?></td>
<td><?= $row['username'];?></td>
<td><?= $row['email'];?></td>
</tr>
<?php
endforeach;
?>
</tbody>
</table>
결과 HTML은 무엇입니까? –
모든 사용자를 얻고 싶다면'fetch()'대신'fetchAll()'을 사용합니다. [오류 처리를 엄격하게 설정하고 로깅] (http://stackoverflow.com/q/1248952/938236)이 있습니까? config.php를 포함하기 전에 오류 메시지가 표시되는지 확인하십시오. –