Hi,

These two files will output the number of records (2) from a MySQL database
but not the record data. Can anyone suggest what I'm doing wrong?

Thanks, Chris

<?php
$dbc = mysqli_connect("localhost", "root", "password", "cjfiles"); 
$results = mysqli_query($dbc, "SELECT * FROM article");
$records = mysqli_num_rows($results);

require_once 'PHPTAL.php';

$template = new PHPTAL('show_articles.html');
$template->results = $results;
$template->records = $records;

try {
   echo $template->execute();
}
catch (Exception $e){
   echo $e;
}
?>

<html>
<head>
</head>
<body>
<h1>Articles</h1>
<h1 tal:content="records">Records</h1>
<table border="1" cellpadding="2" cellspacing="2">
  <tr>
    <th>id</th>
    <th>entitled</th>
    <th>located_at</th>
    <th>written_by</th>
    <th>created_on</th>
    <th>updated_on</th>
    <th>words_long</th>
  </tr>
  <tr tal:repeat="result results">
    <td tal:content="result/id">text replaced by result</td>
    <td tal:content="result/entitled">text replaced by result</td>
    <td tal:content="result/located_at">text replaced by result</td>
    <td tal:content="result/written_by">text replaced by result</td>
    <td tal:content="result/created_on">text replaced by result</td>
    <td tal:content="result/updated_on">text replaced by result</td>
    <td tal:content="result/words_long">text replaced by result</td>
  </tr>
</table>
</body>
</html>
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to