eLIX Posted July 21, 2007 Share Posted July 21, 2007 Hi, I have a problem here. I get data from a database and I need to put in a table. the table dynamically adds rows depending on the results from the database. So my rows are getting created but their's nothing in their. What can be the problem here? <table id="enquetesTable" cellspacing="0"> <tr> <td class="columnTitleLeft">Naam</td> <td class="columnTitle">Aantal Vragen</td> </tr> <!-- BEGIN row --> <tr> <td class="leftColumn"><a href="#">{NAAM}</a></td> <td>{AANTALVRAGEN}</td> </tr> <!-- END row --> </table> <?php function getContent() { require_once('MDB2.php'); // Template directory instellen $tpl_main = new HTML_Template_IT('.'); $tpl_main->loadTemplatefile ('templates/overzicht.tpl', false, false); $tpl_main->setCurrentBlock("row"); // Connectie instellen $dsn = "mysql://usr_enquete:enquete@localhost/enquete"; $mdb2 =& MDB2::connect($dsn, TRUE); if (PEAR::isError($mdb2)) { die($mdb2->getMessage()); } // SQL $res =& $mdb2->query('SELECT * FROM enquetes'); // Altijd kijken of er geen errors zijn if (PEAR::isError($res)) { die($res->getMessage()); } else { // Haal alle data op tot er geen rijen meer over zijn while (($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC))) { $tpl_main->setVariable("NAAM", $row['Naam']); $tpl_main->setVariable("AANTALVRAGEN", $row['AantalVragen']); $tpl_main->parseCurrentBlock(); } } $mdb2->disconnect(); return $tpl_main->get(); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.