Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
BamBamPSK
Regular
Regular



Joined: Nov 11, 2003
Posts: 61

PostPosted: Mon Jan 19, 2004 6:21 pm Reply with quote

hey raven you are the man when it comes to php coding so i come here to get help..thanks you for your site

and now for my "thing"

i have a scrolling forums block on my site that i LOVE it puts dividers between entries but it doesnt do exactly what i want it to do.

it shows the forums i want it to but it counts the "private" forums for the count in the block itself.

like if i had say 6 entries in the public forums and 4 in the private forums the count in the forums block is 6 not 10 like i would like it to be..

hope that makes sense....any who here is the code for the block if i could get it to show and count ONLY the public forums that would be great.

Code:
if (eregi("block-Forums.php", $_SERVER['PHP_SELF'])) {

    Header("Location: index.php");
    die();
}
############################################
#### To remove top fixed link of forum put 0
$toplink = 1;
############################################
#### To stop scroll put 0
$scroll = 1;
############################################
#### To remove the counter put 0
$number = 0;
############################################
#### To remove the search link put 0
$search = 1;
############################################

include_once ('blocks/smileys.php');
$ThemeSel = get_theme();

global $sitename, $prefix, $db, $ThemeSel;
$count = 1;

if ($toplink == 1) {
$content .= "<center><a href=\"forums.html\"><b>$sitename Forums</b></a></center><br>";
}
if ($scroll == 1) {
     $content .="<A name= \"scrollingCode\"></A>";
     $content .="<MARQUEE behavior= \"scroll\" align= \"center\" direction= \"up\" height=\"220\" scrollamount= \"2\" scrolldelay= \"20\" onmouseover='this.stop()' onmouseout='this.start()'>";
     $content .="<br>";
#####################################################################################
################# This will only appear if it's scrolling ###########################
     $content .="<center><b>Last 10 Messages</b></center><br>";
     }
#####################################################################################
############# To change the number of posts change the number in the end of this line
$sql = "SELECT topic_title, topic_last_post_id, forum_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC LIMIT 10";
#####################################################################################
   

    $result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)){
    $topic_title = $row[topic_title];
    $topic_last_post_id = $row[topic_last_post_id];
    $forum_id = $row[forum_id];
    $sql = "SELECT forum_id, forum_name FROM ".$prefix."_bbforums where forum_id='$forum_id'";
    $result2 = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result2);
    $forum_id = $row[forum_id];
    $forum_name = $row[forum_name];
    $sql = "SELECT poster_id, FROM_UNIXTIME(post_time,'%b %d, %Y at %T') as post_time FROM ".$prefix."_bbposts where post_id='$topic_last_post_id'";
    $result3 = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result3);
    $poster_id = $row[poster_id];
    $post_time = $row[post_time];
    $sql = "SELECT username, user_id FROM ".$prefix."_users where user_id='$poster_id'";
    $result4 = $db->sql_query($sql);
    $row = $db->sql_fetchrow($result4);
    $username = $row[username];
    $user_id = $row[user_id];
    $sql2 = "SELECT auth_view, auth_read FROM ".$prefix."_bbforums WHERE forum_id='$forum_id'";
    $result5 = $db->sql_query($sql2);
    $row2 = $db->sql_fetchrow($result5);
    $auth_view = $row2[auth_view];
    $auth_read = $row2[auth_read];
if (($auth_view < 2) OR ($auth_read < 2)) {
    if ($number == 1) {
    $content .= "<table><tr><td><b>Message: $count<br></b></td></tr>";
    } else {
   $content .= "<table>";
   }
    $topic_title=parseEmoticons($topic_title);
   if (file_exists("themes/$ThemeSel/forums/images/icon_minipost.gif")) {
$content .= "<tr><td><img src=\"themes/$ThemeSel/forums/images/icon_minipost.gif\" border=\"0\" alt=\"\"><a href=\"modules.php?name=Forums&amp;file=viewtopic&amp;p=$topic_last_post_id#$topic_last_post_id\" STYLE=\"text-decoration: none\"><b> $topic_title </b><br></a>Last Message by <A HREF=\"forum-userprofile-.html$user_id\"STYLE=\"text-decoration: none\"> <i><strong>$username</strong></i> </a> in <a href=\"modules.php?name=Forums&amp;file=viewforum&amp;f=$forum_id\" STYLE=\"text-decoration: none\"><b>$forum_name</b></a> on <i><strong>$post_time</strong></i><hr></td></tr></table>";
    } else {
$content .= "<tr><td><img src=\"modules/Forums/templates/subSilver/images/icon_minipost.gif\" border=\"0\" alt=\"\"><a href=\"modules.php?name=Forums&amp;file=viewtopic&amp;p=$topic_last_post_id#$topic_last_post_id\" STYLE=\"text-decoration: none\"><b> $topic_title </b><br></a>Last Message by <A HREF=\"forum-userprofile-.html$user_id\"STYLE=\"text-decoration: none\"> <i><strong>$username</strong></i> </a> in <a href=\"modules.php?name=Forums&amp;file=viewforum&amp;f=$forum_id\" STYLE=\"text-decoration: none\"><b>$forum_name</b></a> on <i><strong>$post_time</strong></i><hr></td></tr></table>";
    }
   }
    $count = $count + 1;
   }
if ($toplink == 0) {
$content .= "<center><a href=\"forums.html\"><b>$sitename Forums</b></a></center><br>";
}
if ($scroll == 1){
$content .= "</MARQUEE>";
}
if($search == 1){
$content .= "<center><a href=\"modules.php?name=Forums&file=search\"><b>Search Forums</b></a></center><br>";
}
?>

_________________
Image 
View user's profile Send private message
BamBamPSK







PostPosted: Tue Jan 20, 2004 7:07 am Reply with quote

any one?
 
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Tue Jan 20, 2004 7:33 am Reply with quote

I'm not clear on what you want. If you have 6 in public and 4 in private, do you want to only see the public count, which would be 6?
 
View user's profile Send private message
BamBamPSK







PostPosted: Tue Jan 20, 2004 1:56 pm Reply with quote

ok ill try to explain better....

the block says it will show the last 10 forum messages BUT it really doesnt unless those messages are in the public forums.

when my clan members post in the private section or i and the other admins post in the admin section then those posts count in the forums block...what i want it for those posts NOT to count in the block.

hope that explains it better
 
Raven







PostPosted: Tue Jan 20, 2004 2:06 pm Reply with quote

A quick and dirty way might be to alter this line of code from
Code:
$sql = "SELECT topic_title, topic_last_post_id, forum_id FROM ".$prefix."_bbtopics ORDER BY topic_last_post_id DESC LIMIT 10";
to
Code:
$sql = "SELECT topic_title, topic_last_post_id, forum_id FROM ".$prefix."_bbtopics WHERE forum_id NOT IN('ID1','ID2') ORDER BY topic_last_post_id DESC LIMIT 10";

Of course you need to hard code in the ID1, ID2, etc., with real forum ID's to exclude. It could be written automatically with an SQL join or 2, but if you have just a couple forums to block this would be easier.
 
BamBamPSK







PostPosted: Tue Jan 20, 2004 5:47 pm Reply with quote

i have 4 total to block and how would i hard code it in?
 
Raven







PostPosted: Tue Jan 20, 2004 6:14 pm Reply with quote

??? I gave you the code in my above message Laughing
 
BamBamPSK







PostPosted: Tue Jan 20, 2004 6:45 pm Reply with quote

Raven wrote:

Of course you need to hard code in the ID1, ID2, etc., with real forum ID's to exclude. It could be written automatically with an SQL join or 2, but if you have just a couple forums to block this would be easier.
 
Raven







PostPosted: Tue Jan 20, 2004 6:53 pm Reply with quote

This is the code I gave you, in that same post
Code:
$sql = "SELECT topic_title, topic_last_post_id, forum_id FROM ".$prefix."_bbtopics WHERE forum_id NOT IN('ID1','ID2') ORDER BY topic_last_post_id DESC LIMIT 10";
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©