Index.php php require './libs/smarty.class.php';
// this is a file Which Abstracts the db connection functionality - check out pear
$ smarty = new smarty;
$ Smarty-> Template_dir = './templates/default/'; $ hmarty->compile_check = true; // $ smarty-> debugging = true; // $ smarty-> use_sub_dirs = false; // $ smarty-> caching = True; $ db = mysql_connect ("localhost", "root", ""); mysql_select_db ("test"); // this SQL Statement Will Get The 5 MOSTLETLY Added New Items from the Database $ SQL = 'SELECT * '; $ SQL. =' from `News` '; $ SQL. =' Order by` ID` desc '
$ results = mysql_query ($ SQL) OR Die ("Query Failed:". MySQL_ERROR ());
// for Each Result That We got from the databasewhile ($ result) {$ value [] = $ line; // assign this array to smarty ...
} $ smarty-> assign ('news', $ value); / * @! @! @ $! $! #! @ $! @ $! $! @ # @ ~! $ yes, i change it here, I Learn Just a little, knowing That $ ** assign an array caled $ ** to 'news' in * .tplhahahahah ^^, now my que ~ HAS been Solved! * /// Display THE News Page Through the news template $ smarty-> display ('news.tpl');
?> news.tpl "httml xmlns =" http://www.w3.org/1999/xhtml "xml: lang =" en ">
< Meta http-equiv = "content-type" content = "application / xhtml xml; charSet = UTF-8" />
{section = news loop = $ news}
body> html>