I have an issue that I need help resolving. Here are the examples I have.
$template->set_filenames(array(
'body' => 'main_body.tpl')
);
// begin sql here
$sql = "SELECT phpbb_topics.topic_title, phpbb_posts.post_time, phpbb_posts_text.post_text FROM phpbb_topics, phpbb_posts_text, phpbb_posts,phpbb_forums WHERE phpbb_forums.forum_id=phpbb_posts.forum_id AND phpbb_posts.forum_id=24 AND phpbb_posts.post_id=phpbb_posts_text.post_id AND phpbb_posts.topic_id=phpbb_topics.topic_id ORDER BY phpbb_posts.post_id DESC LIMIT 5";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query news ', '', LINE, FILE, $sql);
}
$news_data = array();
While( $topic_data = $db->sql_fetchrow($result) )
{
$news_data [] = $topic_data;
}
if ( !($total_news = count($news_data)) )
{
message_die(GENERAL_MESSAGE, $lang['No_News']);
}
for ($j=0 ; $j< $total_news; $j++)
{
$row_color = ( !($j % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($j % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$template->assign_block_vars('news', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'TOPIC'=>$news_data[$j]['topic_title'],
'TEXT'=>$news_data[$j]['post_text']));
}
// end sql here
//
// Generate the page
//
$template->pparse('body');
The template is here
<td width="100%" valign="top"><div align="center"><center><table width="100%" align="center" cellpadding="6" cellspacing="0" valign="top">
<tr>
<td width="100%">
<table class="forumline" width="100%" cellspacing="1" cellpadding="3" border="0"
align="center" valign="top">
<tr>
<td class="catHead" height="38" width = "100%" align="center"><font size="4">News</font></td>
</tr>
<tr>
<td width = "100%" class="{news.ROW_CLASS}" align="left" valign="top"><span class="postbody"><b>{news.TOPIC}</b></span><br /><span class="postbody">{news.TEXT}<br /></span></td>
</span></td>
</tr>
<tr>
<td class="spaceRow" height="1"><img src="templates/Chronicles/images/spacer.gif" alt
width="1" height="1" /></td>
</tr>
</table>
</td>
This does not work. You can see the output at http://www.orpgs.com
Basicly what I am trying to do is extract 5 records from a mysql server and insert them into my template. I can insert a single record and the count of the records is correct so the sql portion works properly.
I was using an example from another php file to go by and It does work. Just I can't get it to work here. Any suggestions would be welcom.