show databasetable
| From: | Michael Temeschinko | Date: | Fri, 16 Mar 2001 21:49:48 +0000 |
| Subject: | show databasetable | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-396@lists.php.net to get a copy of this message | ||
>> How do I show database-content with Smarty?
>use:
> $result = mysql_query("SELECT * FROM foo");
> while ($record = mysql_fetch_array($result) {
> $rows[] = $record;
>}
>$smarty->assign("customer", $rows);
hm maybe I have an error in my template
I have a table in my database called "Abteilungen"
Abteilungen
Fields : Abteilung varchar(50)
ID int
-------
{config_load file=lang.conf section="deutsch"}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<table border=0>
<tr>
<td>
{section name=wgruppe loop=$warengruppe}
{$wgruppe/Abteilung}<br>
{/section}
</td>
</tr>
</table>
</body>
</html>
<?php
require("Smarty.class.php");
require("dbi.inc");
$smarty = new Smarty;
$smarty->compile_check = true;
$sql = "select Abteilung from Abteilungen";
$wg = mysql_db_query($database, $sql, $dbh);
while ($warengruppe = mysql_fetch_array($wg)) {
$smarty->append($warengruppe);
}
$smarty->display('left_zeromargins.tpl');
?>
sorry I use templates the first time ....
With friendly greetings from Germany
Michael Temeschinko