...

View Full Version : assign This with Smarty



ajloun
01-27-2010, 08:29 PM
Hello

This Code gets the Data from The Mysql and Prints the Result in Columns , How to assign that into Template with Smarty .. i saw Tutorial Here but the Code was Messed up.
http://smarty.incutio.com/?page=SmartyColumnsTutorial

My code.

// Connect host
$con=@mysql_connect($db_host,$db_user,$db_pass) or die ('No Connect');
// Select db
$sel=@mysql_select_db($db_name,$con) or die ('No Select');
//////////////////////////////////////////////////////////////////////////////////////////
$count=0;
$cols=3; //coumnts #
//read data
$sql=mysql_query("select * from test");

echo"<table border='1' width='50'>\n";

while($row=mysql_fetch_array($sql)){

if($count == 0) echo "<tr>\n";

$count++;

echo "<td>".$row['name']."</td>\n";

if($count==$cols){

echo "</tr>\n";

$count=0;
}
}
echo "</table>";

JAY6390
01-27-2010, 08:39 PM
Here is the quick start guide
http://www.smarty.net/quick_start.php
It's just a matter of assigning values using

$smarty->assign('templat_var_name', $variable);
You can assign a whole array if you wish. Smarty templates allow most if not all php functionality



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum