Hi kaaposc,

> first of all, the value returned by "mysqli_query" is a 
> resource, not a resultset. You have to use one of "fetch" 
> functions to get a resultset. 
> fetch function gives you one row at a time, so you could 
> create an array of these rows and in phptal template use 
> "repeat:" functionality like this:
> <table>
>   <tr tal:repeat="row result">
>     <td tal:content="row/id">text replaced by result</td>
>     <td tal:content="row/entitled">text replaced by result</td>
>     <td tal:content="row/located_at">text replaced by result</td>
>     <td tal:content="row/written_by">text replaced by result</td>
>     <td tal:content="row/created_on">text replaced by result</td>
>     <td tal:content="row/updated_on">text replaced by result</td>
>     <td tal:content="row/words_long">text replaced by result</td>
>   </tr>
> </table>
> (given "result" is an array of fetched rows)
> 
> hth,
> kaaposc

Yes, it did help. No changes needed to the HTML, but the PHP now works using
mysqli_fetch_array() and array_push():

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

$items = array();
while ($row = mysqli_fetch_array($query_resource, MYSQL_BOTH)) {
  array_push($items, $row);
}

require_once 'PHPTAL.php';

$template = new PHPTAL('try0.html');
$template->items = $items;
$template->records = $records;

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

Many thanks, Chris


_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to