A
Anonymous
Guest
It is my first time to use template engines in my coding so I don't know how to make even sample things work.
index.php
index.tpl
It is showing one row ONLY while there is 200 rows in the database!
index.php
Code:
<?php
// Coded by S.Moh'd Ameen | in: 30/03/2006
// e-mail: ameenov@gmail.com
// include smarty
/////////////////////////////////
require '../libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = true;
//////////////////////////////
$smarty->assign("Title","News Page");
//////////////////////////////////////// DB CODES
/// include DB connection
include ('includes/config.php');
////
$query = mysql_query("SELECT * FROM news ORDER BY ID DESC") Or die(mysql_error());
/////////// check if there is result
$show_num = mysql_num_rows($query);
if ($show_num <=0) {
$smarty->assign("Error","No news add yet!");
}else {
//////////// END check if there is result
while($show = mysql_fetch_array($query)){
extract($show);
$Text= stripslashes ($show ['Text']);
///////////// THIS PART I DON"T know if it is right
$smarty->assign("message", array (array("ID" => "$ID", "Text" => "$Text")));
////////////
} // end while
} // end if no result
//////////////////////////////////////// END CODES
$smarty->display('index.tpl');
////////////////////////////////////////////////////////////////////////////
?>
index.tpl
Code:
<title>{$Title}</title>
{$Error}
{section name=sec1 loop=$message}
ID: {$message[sec1].ID}<br>
Text: {$message[sec1].Text}<br>
{/section}
It is showing one row ONLY while there is 200 rows in the database!