Reputation: 1
this is my controller challenges.php
<?php
include("../../tbs_3150/tbs_class.php");
include("../connect.php");
$tbs = new clsTinyButStrong;
try {
$pdo = new PDO($host, $login, $password);
$message = "connexion établie";
if(isset($_GET["category"])){
$res = $pdo->prepare("SELECT * FROM `challenge`
WHERE `categoryId`=:categoryId;");
$res->bindParam(":categoryId",$_GET["category"]);
$res->execute();
$rows = $res->fetchAll(PDO::FETCH_ASSOC);
$tbs->MergeBlock("row",$rows);
}
} catch (PDOException $erreur) {
$message = $erreur->getMessage();
}
$tbs->LoadTemplate("../views/challenges.html");
$tbs->Show();
?>
this is my view
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>[onshow.message]</title>
</head>
<body>
<h1>[onshow.message]</h1>
<table>
<thead>
<tr>
<th>ID</th>
<th>Nom</th>
<th>Description</th>
<!-- Ajoutez d'autres colonnes si nécessaire -->
</tr>
</thead>
<tbody>
[row;block=begin]
<tr>
<td>[row.challengeId]</td>
<td>[row.title]</td>
<td>[row.description]</td>
</tr>
[row;block=end]
</tbody>
</table>
</body>
</html>
i know that i'm correctly querying my database but the problem is that tbs is not formating my view with the values i retreive from the db,so this is the result :
i'm expecting [row.description] to be replaced by its actual value on the database
Upvotes: 0
Views: 34
Reputation: 5552
$tbs->LoadTemplate("../views/challenges.html");
should be placed before
$tbs->MergeBlock("row",$rows);
otherwise you're merging an empty source.
Upvotes: 0