SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2006
    Location
    East Yorkshire, UK
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    phpbb code mod help

    hello everyone,

    Right i have posted this in the phpbb support forums and have not had a reply yet.

    What i am wanting to do is disply the forum names, and the ammount of topics in that forum on EVERY page in the forum. So it would look like this

    FORUM NAME (98)

    (98) Being the number of topics in that forum.

    Now i have actualy got the forumnames displaying on EVERY page, but i cant figure out how id get the ammount of topics in there.

    I am putting this code into the page_header.php page, here is the code i have used

    PHP Code:
    $sql "SELECT c.cat_id, c.cat_title, c.cat_order
       FROM " 
    CATEGORIES_TABLE " c
       ORDER BY c.cat_order"
    ;
    if( !(
    $result $db->sql_query($sql)) )
    {
       
    message_die(GENERAL_ERROR'Could not query categories list'''__LINE____FILE__$sql);
    }
    $category_rows = array();

    while( 
    $category_rows[] = $db->sql_fetchrow($result) );

    for(
    $x=0;$x<(count($category_rows)-1);$x++)
    {
        
    $template->assign_block_vars('switch_show_sidebar', array(
                
    'ID' => $category_rows[$x][0],
                
    'TITLE' => $category_rows[$x][1],
                
    'ROW_COLOR' => 'row1'
                
    ));
                
    $sql2 "SELECT forum_id, forum_name
               FROM " 
    FORUMS_TABLE "
                WHERE  cat_id = '"
    .$category_rows[$x][0]."' ORDER BY forum_order";

                    if( !(
    $result2 $db->sql_query($sql2)) )
                    {
                       
    message_die(GENERAL_ERROR'Could not query categories list'''__LINE____FILE__$sql2);
                    }
                    
    $category_rows_forums = array();
                    while( 
    $category_rows_forums[] = $db->sql_fetchrow($result2) );

                    for(
    $y=0;$y<(count($category_rows_forums)-1);$y++)
                    {
                        
    $template->assign_block_vars('switch_show_sidebar.switch_show_sidebar_forums', array(
                                
    'ID' => $category_rows_forums[$y][0],
                                
    'TITLE' => '<a href="'.append_sid('viewforum.'.$phpEx.'?f='.$category_rows_forums[$y][0].'').'" class="mainmenu">'.$category_rows_forums[$y][1].'</a>',
                                
    'ROW_COLOR' => 'row2'
                                
    ));


                    }
                    
    $db->sql_freeresult($result2);
    }
    $db->sql_freeresult($result); 
    Thanks in advance
    Chris
    I don't have an adictive personality! ,I just can't say no is all

  2. #2
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do a "SELECT COUNT(*) FROM " . TOPICS_TABLE . " WHERE forumid = $id", changing the variable and constant names (as I am guessing the names).
    Inefficient though, maybe you could implement a topic count field in the forums table if there is none currently? Might be a bit hard though as you have to modify this every time a topic is created, deleted, moved etc.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2006
    Location
    Dundee, Scotland
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    presumably you have not noticed that there is a function that gets this information for you?

    get_db_stat('topiccount') is what you would use to get the number of topics.
    $board_config['sitename'] contains the name of the site.



    **Sorry Misread the topic**


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •