Нещата за промяна са:
forum_id=2
t.forum_id = 2
Като цифрата е номера на категорията от която скрипта да вади информацията си.
Скрипта:
Код: Избери целия код
<?php
$conn = new mysqli("localhost", "working", "working", "working");
if (!$conn) {
echo "Error: Не мога да се свържа с MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
mysqli_set_charset($conn,"utf8");
$forum_path = ".././forums/";
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $forum_path;
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_display.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup('viewforum');
$request->enable_super_globals();
//we need it for db connection
require($forum_path . 'config.php');
$bb_db = $dbname;
$bb_prefix = preg_replace("/[^A-Za-z0-9 ]/", '', $table_prefix);
$check_forumid = mysqli_query($conn,"SELECT COUNT(`topic_id`) FROM phpbb_topics WHERE forum_id=2");
$mysql = mysqli_query($conn,"SELECT t.topic_id, t.topic_posts_approved, t.topic_title, t.topic_last_post_id, t.forum_id, p.enable_smilies, p.enable_magic_url, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.post_id, p.post_text, p.poster_id, p.post_time, u.user_colour, u.user_id, u.username FROM phpbb_topics t, phpbb_forums f, phpbb_posts p, phpbb_users u WHERE t.forum_id = 2 AND f.forum_id = t.forum_id AND t.topic_id = p.topic_id AND p.post_id = t.topic_first_post_id AND p.poster_id = u.user_id ORDER BY p.topic_id DESC LIMIT 0,5");
if(mysqli_num_rows($check_forumid) > 0) {
while ($row = mysqli_fetch_assoc($mysql)) {
$news_id = $row['topic_id'];
$forum_id_news = $row['forum_id'];
$news_username = $row['username'];
$news_date = date('F j, Y, g:i a', $row['post_time']);
$news_title = $row['topic_title'];
$news_comments = $row['topic_posts_approved'];
$news_text = generate_text_for_display($row['post_text'],$row['bbcode_uid'],$row['bbcode_bitfield'],7,true,true,true);
$phpbb_topic_url = 'forum/viewtopic.php?f='.$forum_id_news.'&t='.$news_id.'';
echo "
<a href='$phpbb_topic_url'>$news_title</a> by $news_username • $News_date • $news_comments <br />
$news_text
";
}
}