Re: Database results example
| From: | Monte Ohrt | Date: | Mon, 29 Jan 2001 15:34:51 +0000 |
| Subject: | Re: Database results example | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-20@lists.php.net to get a copy of this message | ||
Here is how one example might look using a mysql class (code untested):
index.php:
----------
<?php
require("Smarty.class.php");
require("MySQL.class.php");
$sql = new MYSQL;
$smarty = new Smarty;
// select all data as one large array
$sql->query("select firstname,lastname from users",SQL_ALL);
$smarty->assign($sql->record);
$smarty->display("index.tpl");
?>
index.tpl:
----------
<HTML>
<BODY>
{section name=userinfo loop=$firstname}
{$userinfo/firstname} {$userinfo/lastname}<br>
{/section}
</BODY>
</HTML>
Pablo Martinez wrote:
>
> Does anyone have an example of how to display the results of a database
> query?
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/