Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

PEAR::DB & Smarty + html_table

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
mistermatt
Smarty n00b


Joined: 09 Sep 2003
Posts: 2

PostPosted: Tue Sep 09, 2003 6:19 pm    Post subject: PEAR::DB & Smarty + html_table Reply with quote

At present I am trying a very simple example, using some of the wisdom acquired from Tom A's 'SmartestSmarty Practices' article. I am stumbling when I try to use html_table to output the results of a getAll query.

My PHP script uses PEAR::DB to getAll on 2 columns in a 7 column MySQL table. I am working with a single TPL file, which uses a Smarty html_table statement to loop through the result (well, thats my intent). Index.php currently gives me a blank page when loading it. Everything loads correctly, minus the data, if I replace the {html_table} statement with, say, <b> hello there </b>.

Also of note: mode is DB_FETCHMODE_ASSOC, caching is off and force_compile is on

What follows is my code:

index.php
Code:

<?
require_once('/var/www/htdocs/pst/set_env.php');
$t->assign('title', 'Hello');
$t->assign('data', $db->getAll('Select Name, PhoneNumber FROM Physician'));
$t->display('topmenu.tpl');
?>


topmenu.tpl
Code:

{include file="/var/www/htdocs/pst/templates/html_header.tpl"}
{html_table cols=2 loop=$data}
{include file="/var/www/htdocs/pst/templates/html_footer.tpl"}


Any guidance would be most appreciated.
_________________
regards,

matt
Back to top
View user's profile Send private message
mistermatt
Smarty n00b


Joined: 09 Sep 2003
Posts: 2

PostPosted: Fri Sep 12, 2003 12:15 am    Post subject: html_table questions continued Reply with quote

I sure wish I had made my first thread topic 'Newbie is confused about html_tables.' I have been unable to find guidance on this topic through the Forums, Wikis, Docs or even the occasional groups.google.com.

Having retreived all (SELECT *) rows successfully from a 7 column table (Physician), I am wondering how this information is best fed to {html_table} later in my template. Documentation has told me that loop= needs an array, whose elements, I'm assuming, must be strings. Well, my results are likely going to be an ordered or associative array (whose array elements are arrays). Any tips on how I could handle this situation would be most appreciated!!!

What follows is my index.php file. The index.tpl file has not changed with the exception of the loop= var name.

Code:

<?
require_once('/var/www/htdocs/pst/include/set_env.php');
$t->assign('title', 'Hello');

$result = $db->getAll("SELECT * FROM Physician");
if (DB::isError($result))
      echo $result->getMessage();
print_r($result);
$t->assign('result', $result);
$t->assign('name', 'Joe');
$t->display('index.tpl');
?>


Thank You.
_________________
regards,

matt
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP