Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

how to limit this query code to a special forum

Ads
banner
banner
banner
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#1
Member
Hello
I found this query code in a plugin :
Code:
       SELECT t.tid, t.fid, t.subject, t.lastpost,
       t.lastposter, t.lastposteruid, f.name,
       u.usergroup, u.displaygroup
       FROM ".TABLE_PREFIX."threads AS t
       INNER JOIN ".TABLE_PREFIX."forums as f
       ON (f.fid = t.fid)
       LEFT JOIN " . TABLE_PREFIX . "users AS u
       ON (t.lastposteruid = u.uid)
       {$fids}
       AND t.visible = '1'
       GROUP BY t.tid
       ORDER BY t.lastpost DESC
       LIMIT

now, I want to know how can I limit it to a special forum
for example limit it to a forum that its FID is 2

thanks
Heart
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#2
Support Team
Without knowing the rest of the code it's hard to come up with a fix.

You can do something like this:

PHP Code:
while($forum $db->fetch_array($query))
{
if(
$forum['fid'] == 
{
//do some stuff when forum fid is 2
}


Put this code below your SQL query and add f.fid to the it.


Or:

PHP Code:
$query $db->simple_select('forums''fid');
 while(
$forum $db->fetch_array($query))
    {
if(
$forum['fid'] == 
{
// the rest of you PHP code here
}



What are you trying to do?
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#3
Member
Thanks, I want to change this mod :
http://mods.mybb.com/view/recent-posts-forum-index

instead of showing recent post I want to show recent post of my own category
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#4
Support Team
Are you trying to do something like I have in these forums?

Latest threads in Category and Forum? If so you can use these: http://community.mybb.com/thread-153867-...pid1079115
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#5
Member
No, this mod :
http://mods.mybb.com/view/recent-posts-forum-index
shows recent posts of all the forum

I want to show recent posts (for example of Design & Development)
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#6
Support Team
I have already told you that this is what you need: http://letsforum.com/Thread-how-to-limit...36#pid9536
There are two plugins 1 for forum another for category.
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#7
Member
where does it shows recent post ?
needs any variable ?
marcus_avrelius Offline referral

Posts: 2,424
Joined: May 2013
Reputation: 102

#8
Support Team
I am gonna try to modify recent-posts-forum-index plugin so that it will fetch latest posts from forum fid 2.

OK looks like I have found the solution.

In the plugin file find:
PHP Code:
//Preserve the forum viewing permissions intact
        
         
$fids "WHERE t.fid NOT IN ({$unviewablefids})";
        
$unviewablefids get_unviewable_forums();
        
        if(
$unviewablefids)
        {
            
$fids "WHERE t.fid NOT IN ({$unviewablefids})";
        }
        
        
//Exclude inactive forums from showing up
        
        
$inactivefids get_inactive_forums();
        if (
$inactivefids)
        {
            
$fids .= " WHERE t.fid NOT IN ($inactivefids)";
        } 

Replace with:

PHP Code:
$forumid 2;
$fids "WHERE f.fid IN ({$forumid})"

This will only poll last posts from forum FID 2.
Looking for ways to make money fast? Read this article and start earning money todya fast, easy or for free.
lion Offline referral

Posts: 122
Joined: May 2014
Reputation: 0

#9
Member
Thanks marcus, this is what I needed
+1





User(s) browsing this thread: 1 Guest(s)