user3790450
user3790450

Reputation: 55

How to output database entry in template file?

How can I output something from my database in a tpl file? Can I just add the php code to the .tpl. It's just a simple text from my database to be shown in my footer, whats the best way to do this? Here's my output code:

$sql = "SELECT `version` FROM `versionierung`";

$abfrageergebnis = mysql_query( $sql, $conID );


while ($datensatz = mysql_fetch_array( $abfrageergebnis ))
{    

echo "<tr>";
echo "<td>" .htmlspecialchars( $datensatz['version'] ). "</td>";
echo "</tr>";
}

Upvotes: 0

Views: 51

Answers (1)

Keerthi Bandara
Keerthi Bandara

Reputation: 159

if you are using smarty here, you can use 'assign' functions/tags accordingly. Smarty doc provides more details with samples, http://www.smarty.net/docs/en/language.function.assign.tpl

Eg.

<?php

$smarty->assign('foo','Your value');

Upvotes: 1

Related Questions