Jump to content

Got data from database but doesn't show


eLIX

Recommended Posts

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();
}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.