How to get values from a getAll / getAssoc - Array ?
| From: | ts | Date: | Tue, 29 Apr 2003 12:44:25 +0000 |
| Subject: | How to get values from a getAll / getAssoc - Array ? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5120@lists.php.net to get a copy of this message | ||
I'm using Smarty-Templates.
The connection to PostgreSQL works and a get 12 rows from my select.
.....
$db = DB::connect($dsn, TRUE);
$sql = "SELECT pid, name, vorname FROM t_bew_schueler";
$res = $db->query($sql); $rows = $res->numRows(); // this says, i've 12 Rows to display!
$schueler = $db->getAssoc($query);$tpl->assign("rows", $rows); $tpl->assign("schueler", $schueler); $tpl->displayTemplate(); //////////////////////////////////////////////////////////////////////// Here some code from the template: first, I tried to show the result with this: <table> <tr>
<td> PID </td><td> Vorname </td>
<td> Name </td></tr> {section name="i" loop=$schueler} <tr>
<td> {$schueler[i].schueler_id} </td>
<td> {$schueler[i].schueler_vorname} </td>
<td> {$schueler[i].schueler_name} </td>
</tr>
{/section}
</table>
*_No error occured here but i've only 3 rows with nothing in it !_*
second try:
{foreach item=i from=$schueler}
<br> {$i.pid}, {$i.vornanme}, {$i.name}
{/foreach}
*_There's also no error here and it shows 8 lines with only a "D,D,D" in line 5 ! _*
It's a little bit frustrating right now, so PLEASE help me showing what i do wrong.
Thanks in advance,
Torsten