mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Redo querying structure
git-svn-id: file:///svn/phpbb/trunk@27 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
3c73050aac
commit
f040ef160e
1 changed files with 66 additions and 59 deletions
|
@ -43,43 +43,50 @@ include('page_header.'.$phpEx);
|
||||||
$template->set_block("body", "catrow", "cats");
|
$template->set_block("body", "catrow", "cats");
|
||||||
$template->set_block("catrow", "forumrow", "forums");
|
$template->set_block("catrow", "forumrow", "forums");
|
||||||
|
|
||||||
$sql = "SELECT * FROM ".CATEGORIES_TABLE." ORDER BY cat_order";
|
$sql = "SELECT c.* FROM ".CATEGORIES_TABLE." c, ".FORUMS_TABLE." f WHERE f.cat_id=c.cat_id GROUP BY c.cat_id ORDER BY c.cat_order";
|
||||||
if(!$result = $db->sql_query($sql))
|
if(!$q_categories = $db->sql_query($sql))
|
||||||
{
|
{
|
||||||
error_die($db, QUERY_ERROR);
|
error_die($db, QUERY_ERROR);
|
||||||
}
|
}
|
||||||
$total_rows = $db->sql_numrows();
|
|
||||||
if($total_rows)
|
|
||||||
{
|
|
||||||
$rows = $db->sql_fetchrowset($result);
|
|
||||||
for($x = 0; $x < $total_rows; $x++)
|
|
||||||
{
|
|
||||||
|
|
||||||
$template->set_var(array("CAT_ID" => $rows[$x]["cat_id"],
|
$total_categories = $db->sql_numrows();
|
||||||
|
|
||||||
|
if($total_categories)
|
||||||
|
{
|
||||||
|
$category_rows = $db->sql_fetchrowset($q_categories);
|
||||||
|
$sql = "SELECT f.*, u.username, p.post_time FROM ".FORUMS_TABLE." f LEFT JOIN ".POSTS_TABLE." p ON p.post_id = f.forum_last_post_id LEFT JOIN ".USERS_TABLE." u ON u.user_id = p.poster_id ORDER BY f.forum_id";
|
||||||
|
if(!$q_forums = $db->sql_query($sql))
|
||||||
|
{
|
||||||
|
error_die($db, QUERY_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
$total_forums = $db->sql_numrows($q_forums);
|
||||||
|
$forum_rows = $db->sql_fetchrowset($q_forums);
|
||||||
|
|
||||||
|
for($i = 0; $i < $total_categories; $i++)
|
||||||
|
{
|
||||||
|
$template->set_var(array("CAT_ID" => $category_rows[$i]["cat_id"],
|
||||||
"PHP_SELF" => $PHP_SELF,
|
"PHP_SELF" => $PHP_SELF,
|
||||||
"CAT_DESC" => stripslashes($rows[$x]["cat_title"])));
|
"CAT_DESC" => stripslashes($category_rows[$i]["cat_title"])));
|
||||||
|
|
||||||
$sub_sql = "SELECT f.* FROM ".FORUMS_TABLE." f WHERE f.cat_id = '".$rows[$x]["cat_id"]."' ORDER BY forum_id";
|
|
||||||
if(!$sub_result = $db->sql_query($sub_sql))
|
|
||||||
{
|
|
||||||
error_die($db, QUERY_ERROR);
|
|
||||||
}
|
|
||||||
$total_forums = $db->sql_numrows($sub_result);
|
|
||||||
$forum_rows = $db->sql_fetchrowset($sub_result);
|
|
||||||
|
|
||||||
if($total_forums)
|
|
||||||
{
|
|
||||||
$template->parse("cats", "catrow", true);
|
$template->parse("cats", "catrow", true);
|
||||||
for($y = 0; $y < $total_forums; $y++)
|
|
||||||
|
for($j = 0; $j < $total_forums; $j++)
|
||||||
|
{
|
||||||
|
if($forum_rows[$j]["cat_id"] == $category_rows[$i]["cat_id"])
|
||||||
{
|
{
|
||||||
$folder_image = "<img src=\"images/folder.gif\">";
|
$folder_image = "<img src=\"images/folder.gif\">";
|
||||||
$posts = $forum_rows[$y]["forum_posts"];
|
$posts = $forum_rows[$j]["forum_posts"];
|
||||||
$topics = $forum_rows[$y]["forum_topics"];
|
$topics = $forum_rows[$j]["forum_topics"];
|
||||||
$last_post = $forum_rows[$y]["forum_last_post"];
|
if($forum_rows[$j]["username"] != "" && $forum_rows[$j]["post_time"] > 0){
|
||||||
$last_post = date($date_format, $last_post);
|
$last_post_user = $forum_rows[$j]["username"];
|
||||||
$last_post_user = get_userdata_from_id($forum_rows[$y]["forum_last_post_uid"], $db);
|
$last_post_time = date($date_format, $forum_rows[$j]["post_time"]);
|
||||||
|
$last_post = $last_post_time." by ".$last_post_user;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$last_post = "";
|
||||||
|
}
|
||||||
|
|
||||||
$last_post = $last_post . "<br>" . $last_post_user["username"];
|
|
||||||
$moderators = "<a href=\"profile.$phpEx?mode=viewprofile&user_id=1\">theFinn</a>";
|
$moderators = "<a href=\"profile.$phpEx?mode=viewprofile&user_id=1\">theFinn</a>";
|
||||||
if($row_color == "#DDDDDD")
|
if($row_color == "#DDDDDD")
|
||||||
{
|
{
|
||||||
|
@ -90,9 +97,9 @@ if($total_rows)
|
||||||
$row_color = "#DDDDDD";
|
$row_color = "#DDDDDD";
|
||||||
}
|
}
|
||||||
$template->set_var(array("FOLDER" => $folder_image,
|
$template->set_var(array("FOLDER" => $folder_image,
|
||||||
"FORUM_NAME" => stripslashes($forum_rows[$y]["forum_name"]),
|
"FORUM_NAME" => stripslashes($forum_rows[$j]["forum_name"]),
|
||||||
"FORUM_ID" => $forum_rows[$y]["forum_id"],
|
"FORUM_ID" => $forum_rows[$y]["forum_id"],
|
||||||
"FORUM_DESC" => stripslashes($forum_rows[$y]["forum_desc"]),
|
"FORUM_DESC" => stripslashes($forum_rows[$j]["forum_desc"]),
|
||||||
"ROW_COLOR" => $row_color,
|
"ROW_COLOR" => $row_color,
|
||||||
"PHPEX" => $phpEx,
|
"PHPEX" => $phpEx,
|
||||||
"POSTS" => $posts,
|
"POSTS" => $posts,
|
||||||
|
@ -100,14 +107,14 @@ if($total_rows)
|
||||||
"LAST_POST" => $last_post,
|
"LAST_POST" => $last_post,
|
||||||
"MODERATORS" => $moderators));
|
"MODERATORS" => $moderators));
|
||||||
$template->parse("forums", "forumrow", true);
|
$template->parse("forums", "forumrow", true);
|
||||||
}
|
} // if ... then
|
||||||
|
} // for total forums
|
||||||
$template->parse("cats", "forums", true);
|
$template->parse("cats", "forums", true);
|
||||||
$template->set_var("forums", "");
|
$template->set_var("forums", "");
|
||||||
}
|
} // for ... categories
|
||||||
}
|
|
||||||
}
|
|
||||||
$template->pparse("output", "body");
|
|
||||||
|
|
||||||
|
}// if ... total_categories
|
||||||
|
$template->pparse("output", "body");
|
||||||
|
|
||||||
include('page_tail.'.$phpEx);
|
include('page_tail.'.$phpEx);
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue