테이블로 인쇄하려고하지만 PDO 사용 방법을 모르겠습니다. 내 시도를 Heres. PDO 테이블에 출력 인쇄
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover table-condensed">
<thead>
<tr>
<th>Modules from Current Course</th>
<th>Modules from New Course</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
require_once('connect.php');
$sql = "SELECT CourseID, Module_Name,ModuleID, Module_Code, Module_Year FROM
coursemodule ORDER BY ModuleID ASC";
$stmt = $db->prepare($sql);
$stmt->bindParam(':ModuleID', $CourseID, PDO::PARAM_INT);
$stmt->execute();
while ($output = $stmt->fetch(PDO::FETCH_OBJ)) {
echo "<p>" . $output->Module_Name . " " . $output->Module_Code . "</p>\n";
}
및
은 내가 다음 쿼리에서 데이터를 저장하는 테이블에 그것을 밖으로 인쇄 할 필요가 알고 있지만 어떤 시도는 어디에도 이어질 없다. 누구든지 도와 줄 수 있습니까?EDIT 최신 시도
try
{
$sql = "SELECT * FROM coursemodule WHERE ModuleID=?";
$stmt = $db->prepare($sql);
$stmt->execute(array(
$_POST['ModuleID']
));
$result = $stmt->fetchAll();
?>
<h1>Course Modules</h1>
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover table-condensed">
<thead>
<tr>
<th>ID</th>
<th colspan="3"></th>
</tr>
<?php
foreach ($result as $row)
{
<tr>
<td>echo {$row['ModuleID']}</td>
<td>
} // End Foreach
?>
</tbody>
</table>
</div>
오류 받기 '구문 분석 오류 : 구문 오류, 예기치 않은'< ''표에 반향 내 시도와 관련.
http://php.net/pdo.prepared-statements) 도움이 될 것이다. 또한 오류를 확인합니다. –
테이블에 내용을 인쇄하려면 행과 열을 추가해야합니다. 현재 코드는 모듈 이름과 모듈 코드로 단락을 반향 출력합니다. 당신의 쿼리는 아무것도 반환하지 않습니까? 문제가 발생하는 곳은 어디입니까? – ymas
@ymas querry가 작동 중이며 테이블 밖으로 잘 인쇄됩니다. 모듈 이름/코드를 저장 한 다음 테이블 클래스에서 다시 열어 인쇄하는 방법을 모르겠습니다. – mkra