Need help modifying

Discussion in 'PHP' started by jWebXpress, Aug 7, 2007.

  1. #1
    Does anyone know what I need to do to show the categories from group id 10 only. Currently, this snippet shows all cats and subcats

    <?php
    // draw the forum table of posts
    drawForumTopics($group_id, "index.php");
    ?>
     
    jWebXpress, Aug 7, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Now I thought I'd be smart and Google the function name to see which forum software this belongs to, but there are no results. So I won't be able to help, unless you post the code of this drawForumTopics() function.
     
    nico_swd, Aug 7, 2007 IP
  3. jWebXpress

    jWebXpress Well-Known Member

    Messages:
    646
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    140
    #3
    Was hoping the above would be enough. Unfortunately the script is encrypted and I cannot seen any code. Really sucks.

    EDIT:

    I think I found the function, I will post in a minute.
     
    jWebXpress, Aug 7, 2007 IP
  4. jWebXpress

    jWebXpress Well-Known Member

    Messages:
    646
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    140
    #4
    I think this should help

    /**
    *
    * function drawForumTopics
    *
    *
    */
    
    function drawForumTopics($group, $link_page)
    {
    
    global $url;
    
    // est a connection
    $dbh = DB::connect(CONNECTION);
    // query the categories based on the parent and then display
    //$sql_topics = $dbh->query("SELECT category_id, category_name, category_desc, group_id FROM ". CATEGORY ." WHERE parent_id = '". $parent_category ."'");
    $sql_topics = $dbh->query("SELECT category_id, category_name, category_desc, group_id, parent_id FROM ". CATEGORY ." WHERE group_id = '". $group ."'");
    if(DB::isError($sql_topics)) return false;
    
    // now we have to display the table full of the topics
    while($row = $sql_topics->fetchRow(DB_FETCHMODE_ASSOC))
    {
    
    // draw the main topics first 
    
    echo "
    <table width='100%' cellpadding='10' cellspacing='0' style='border:1px solid #CCCCCC; background:#FFFFFF; font-size:12px; margin-bottom:4px;'>
    <tr>
    <td style='line-height:20px;' width='450'><strong><a href='". $link_page.createURLVar("page=". $row['group_id']. "_". $row['category_id'] ."_0_0")."'>". $row['category_name']."</a></strong><br>". $row['category_desc']."</td>
    <td valign='top' align='right'>
    <table cellpadding='10' cellspacing='4'>
    <tr>
    <td align='center' width='75' style='background:#EEEEEE; border:1px solid #CCCCCC; line-height:20px;' nowrap><span class='forum_small'>Last post</span><br>". lastPostAuthor($row['category_id'], "db_forum") ."</td>
    <td align='center' width='75' style='background:#EEEEEE; border:1px solid #CCCCCC; line-height:20px;' nowrap><span class='forum_small'>Threads</span><br>". postsPerCategory($row['category_id'], "db_forum")."</td>
    <td align='center' width='75' style='background:#EEEEEE; border:1px solid #CCCCCC; line-height:20px;' nowrap><span class='forum_small'>Replies</span><br>". postsPerCategory($row['category_id'], "comments_db_forum")."</td>
    <td align='center' width='75' style='background:#EEEEEE; border:1px solid #CCCCCC; line-height:20px;' nowrap><span class='forum_small'>Views</span><br>". getTotalCategoryViews($row['group_id'], $row['category_id'])."</td>
    </tr>
    </table></td>
    </tr>
    </table>
    ";
    
    
    
    }
    
    // disconnect
    $dbh->disconnect();
    }
    
    
    
    /**
    *
    * function drawForumTopics
    *
    *
    */
    
    function drawForumSubTopics($parent_category, $link_page)
    {
    
    global $url;
    
    // est a connection
    $dbh = DB::connect(CONNECTION);
    
    // query the categories based on the parent and then display
    $sql_topics = $dbh->query("SELECT category_id, category_name, category_desc, group_id FROM ". CATEGORY ." WHERE category_id = '". $parent_category ."'");
    //$sql_topics = $dbh->query("SELECT category_id, category_name, category_desc, group_id, parent_id FROM ". CATEGORY ." WHERE group_id = '". $group ."'");
    if(DB::isError($sql_topics)) return false;
    
    // now we have to display the table full of the topics
    while($row = $sql_topics->fetchRow(DB_FETCHMODE_ASSOC))
    {
    
    echo "
    <table width='100%' cellpadding='10' cellspacing='0' style='border:1px solid #CCCCCC; background:#EEEEEE; font-size:12px; margin-bottom:4px;'>
    <tr>
    <td style='line-height:20px;' width='450'><strong><a href='". $link_page.createURLVar("page=". $row['group_id']. "_". $row['category_id'] ."_0_0")."'>". $row['category_name']."</a></strong><br>". $row['category_desc']."</td>
    <td valign='top' align='right'>
    <table cellpadding='10' cellspacing='4'>
    <tr>
    <td align='center' width='75' style='background:#EEEEEE; border:1px solid #CCCCCC; line-height:20px;' nowrap><span class='forum_small'>Last post by</span><br>". lastPostAuthor($row['category_id'], "db_forum") ."</td>
    <td align='center' width='75' style='background:#EEEEEE; border:1px solid #CCCCCC; line-height:20px;' nowrap><span class='forum_small'>Replies</span><br>". postsPerCategory($row['category_id'], "db_forum")."</td>
    <td align='center' width='75' style='background:#EEEEEE; border:1px solid #CCCCCC; line-height:20px;' nowrap><span class='forum_small'>Comments</span><br>". postsPerCategory($row['category_id'], "comments_db_forum")."</td>
    </tr>
    </table></td>
    </tr>
    </table>
    ";
    
    }
    
    // disconnect
    $dbh->disconnect();
    }
    Code (markup):
     
    jWebXpress, Aug 7, 2007 IP
  5. xdimension

    xdimension Peon

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I hope I understand your question correctly, if you want to get the categories from group_id = 10 then just change this line:

    <?php
    drawForumTopics(10, "index.php");
    ?>


    but there might be some codes around that line (for example: looping), in that way even your change above will return correct result it wouldn't be efficient (could be looping for the same group_id = 10 result).
     
    xdimension, Aug 7, 2007 IP