I am new in all this moding stuff, but how do i initialize a MySQL connection in phpBB3?
i want to create a shoutbox(sounds easy) but how to connect to the database and then submit the result to the template in {row.shout} stuff?


$text = utf8_normalize_nfc(request_var('mytext', '', true));
$edit_id = request_var('id', 0);
$sql_ary = array(
'text_here' => $text,
'text_id' => $edit_id);
$sql = 'INSERT INTO ' . NEW_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);





$text = utf8_normalize_nfc(request_var('mytext', '', true));
$edit_id = request_var('id', 0);
$sql_ary = array(
'text_here' => $text,
'text_id' => $edit_id);
$sql = 'INSERT INTO ' . NEW_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);



// Search for new topics
$sql = "SELECT topic_id, topic_replies, forum_id, topic_title FROM " . TOPICS_TABLE . " ORDER BY topic_last_post_time DESC LIMIT 0, 5";
$result = $db->sql_query($sql);;
while($topics = $db->sql_fetchrow($result))
{
***********
}
$template->assign_vars(array(
'NEWEST_POST' => $******,
);

Skyler wrote:ok..look what
i added this to index.php
- Code: Select all
// Search for new topics
$sql = "SELECT topic_id, topic_replies, forum_id, topic_title FROM " . TOPICS_TABLE . " ORDER BY topic_last_post_time DESC LIMIT 0, 5";
$result = $db->sql_query($sql);;
while($topics = $db->sql_fetchrow($result))
{
***********
}
$template->assign_vars(array(
'NEWEST_POST' => $******,
);
How can i add the newest post id, name, and so on to the key?
I want to create Recent Topics

$db->sql_query_limit($sql, $limit, $start)$db->sql_query_limit($sql, '5', $start)$template->assign_vars(array(
'N_TOPIC" => $topics['topic_title'],
);
$db->sql_query_limit($sql, 5, 0)$db->sql_query_limit($sql, 5)$template->assign_block_vars('latest_topics', array(
'N_TOPIC" => censor_text($topics['topic_title']),
);
on index_body.html you will have to add:<ul>
<!-- BEGIN latest_topics -->
<li>{latest_topics.N_TOPIC}</li>
<!-- BEGINELSE -->
<li>{L_NO_RECENT_TOPICS}</li>
<!-- END latest topics-->
</ul>
)

// Search for new topics
$sql = "SELECT topic_id, topic_replies, forum_id, topic_title FROM " . TOPICS_TABLE . " ORDER BY topic_last_post_time DESC";
$result = $db->sql_query_limit($sql, 5, 0);
while($topics = $db->sql_fetchrow($result))
{
$template->assign_block_vars('latest_topics', array(
'N_TOPIC' => $topics['topic_title'],
);
}
$db->sql_freeresult($result);when i remove this piece of code
$template->assign_block_vars('latest_topics', array(
'N_TOPIC' => $topics['topic_title'],

Return to phpBB3 Challenges at phpBB Academy
Users browsing this forum: No registered users and 1 guest