Clan Adverts

Custom PHPNuke Scripts

 

www.clan-themes.co.uk :: View topic - Help with code, new forum posts

 Welcome To Clan Themes 

As the board grows please remember the Search Option and we hope you find our community useful.

We also monitor Private Messages to stop members from abusing our sites system.
If you are asking for assistance please provide your site link and nuke version, Thanks.

Help with code, new forum posts

10 Replies / 429 Views


Post new topic   Reply to topic  

   www.clan-themes.co.uk Forum Index » PHPBB

View previous topic :: View next topic


kardson
Reputation: 0.8
Local time: 7:44 AM
Location: Michigan
usa.gif

Status: Offline
0.10 posts per day
Medals: 0

Joined: Apr 28, 2008
Last Visit: 07 May 2008
Posts: 7
Points: 183 

Post Help with code, new forum posts Posted: Fri May 02, 2008 1:51 pm   

Im having a hard time figuring out how to do the following.

I want to grab the new forum posts and put them in an arrary and then display them.
This I have working, The problem is. I do not want it to show the same topic more than once.
Right now if someone posts 3 times in the same topic, it will show that topic 3 times in the block


Code:
// How many posts to display
$PostNumber = "3";

// How many characters from the title to display (0 = show complete title)
$PostLength = "0";

$query = "SELECT *
        FROM nuke_bbposts, nuke_users, nuke_bbtopics, nuke_bbforums
        WHERE nuke_bbposts.topic_id=nuke_bbtopics.topic_id
        AND nuke_bbposts.forum_id=nuke_bbforums.forum_id
        AND nuke_bbposts.poster_id=nuke_users.user_id
      AND nuke_bbforums.forum_id!=7
        ORDER BY post_time DESC LIMIT $PostNumber";

$content .= "<br>";

$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {

  $topic_title = stripslashes($row[topic_title]);

  if($PostLength){
    $topic_title = substr($topic_title, 0, $PostLength) . "...";
  }

  $content .= "<b>$row[forum_name]</b><br>";
  $content .= "<a title=\"$row[topic_title]\" href=\"$urlPath/viewtopic.php?t=$row[topic_id]&sid=$row[forum_id]\">$topic_title</a>   ";
  $content .= "By: $row[username]<br>";
  $content .= "<br>";

}


Thanks for any help, it is appreciated.
 

 
View user's profileSend private messageVisit poster's websiteAIM AddressYahoo Messenger Reply with quote

Untergang
Reputation: 546.9
votes: 1
Local time: 1:44 PM
Location: Lommel
belgium.gif

Status: Offline
0.45 posts per day
Medals: 0

Joined: May 08, 2007
Last Visit: 05 Jul 2008
Posts: 191
Points: 4755 

Post Re: Help with code, new forum posts Posted: Fri May 02, 2008 6:19 pm   

You have to order the wars by topic_last_post_id
So the query becomes like this:
Code:
$query = "SELECT *
        FROM nuke_bbposts, nuke_users, nuke_bbtopics, nuke_bbforums
        WHERE nuke_bbposts.topic_id=nuke_bbtopics.topic_id
        AND nuke_bbposts.forum_id=nuke_bbforums.forum_id
        AND nuke_bbposts.poster_id=nuke_users.user_id
      AND nuke_bbforums.forum_id!=7
        ORDER BY topic_last_post_id DESC LIMIT $PostNumber";
 

 
View user's profileSend private messageSend e-mailVisit poster's websiteMSN Messenger Reply with quote

kardson
Reputation: 0.8
Local time: 7:44 AM
Location: Michigan
usa.gif

Status: Offline
0.10 posts per day
Medals: 0

Joined: Apr 28, 2008
Last Visit: 07 May 2008
Posts: 7
Points: 183 

Post Help with code, new forum posts Posted: Fri May 02, 2008 7:50 pm   

Doesn't appear to be as simple as that.


It does still list them in order, but it still lists the same topic multiple times if the last posts were on the same topic.

I need to find a way to limit it listing the same forum topic id just once


here the the current code
is there a way to only have it list the most recent post on a forum topic just once within the array.
Or would it be an IF statement before outputting the $content


Code:

// How many posts to display
$PostNumber = "3";

// How many characters from the title to display (0 = show complete title)
$PostLength = "14";

$query = "SELECT *
        FROM nuke_bbposts, nuke_users, nuke_bbtopics, nuke_bbforums
        WHERE nuke_bbposts.topic_id=nuke_bbtopics.topic_id
        AND nuke_bbposts.forum_id=nuke_bbforums.forum_id
        AND nuke_bbposts.poster_id=nuke_users.user_id
      AND nuke_bbforums.forum_id!=7
        ORDER BY topic_last_post_id DESC LIMIT $PostNumber";

$content .= "<br>";

$result = mysql_query($query);
while($row = mysql_fetch_array($result)) {

  $topic_title = stripslashes($row[topic_title]);

  if($PostLength){
    $topic_title = substr($topic_title, 0, $PostLength) . "...";
  }

  $content .= "<b>$row[forum_name]</b><br>";
  $content .= "<a title=\"$row[topic_title]\" href=\"$urlPath&file=viewtopic&t=$row[topic_id]&sid=$row[forum_id]\">$topic_title</a>   ";
  $content .= "By: $row[username]<br>";
  $content .= "<br>";

}
 

 
View user's profileSend private messageVisit poster's websiteAIM AddressYahoo Messenger Reply with quote

DreAdeDcoRpSE
Reputation: 632.7
votes: 3
Local time: 7:44 AM
Location: Back of your Mind
usa.gif

Status: Offline
0.97 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)
Forums Moderator
Forums Moderator
Joined: Sep 22, 2007
Last Visit: 05 Jul 2008
Posts: 279
Points: 3948 

View user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger Reply with quote




kardson
Reputation: 0.8
Local time: 7:44 AM
Location: Michigan
usa.gif

Status: Offline
0.10 posts per day
Medals: 0

Joined: Apr 28, 2008
Last Visit: 07 May 2008
Posts: 7
Points: 183 

Post Help with code, new forum posts Posted: Fri May 02, 2008 8:39 pm   

It's for a block on my main page of the phpnuke site.
Such that it displays the most recent posts from the forums module.
But I do not want it to display the same topic twice, if those are the last 2 posts.

So the Block Looks like

Topic 1
Topic 2
Topic 3

not like

Topic 1
Topic 2
Topic 1

or

Topic 2
Topic 2
Topic 1

So I need to find a way to remove all but the most recent instance of each Forum Topic, and im not quite sure how to pull that off.
 

 
View user's profileSend private messageVisit poster's websiteAIM AddressYahoo Messenger Reply with quote

DreAdeDcoRpSE
Reputation: 632.7
votes: 3
Local time: 7:44 AM
Location: Back of your Mind
usa.gif

Status: Offline
0.97 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)
Forums Moderator
Forums Moderator
Joined: Sep 22, 2007
Last Visit: 05 Jul 2008
Posts: 279
Points: 3948 

View user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger Reply with quote

Untergang
Reputation: 546.9
votes: 1
Local time: 1:44 PM
Location: Lommel
belgium.gif

Status: Offline
0.45 posts per day
Medals: 0

Joined: May 08, 2007
Last Visit: 05 Jul 2008
Posts: 191
Points: 4755 

Post Re: Help with code, new forum posts Posted: Sat May 03, 2008 9:07 am   

Try this one
This one should work
Code:
$query = "SELECT *  FROM nuke_bbtopics ORDER BY topic_last_post_id DESC LIMIT 0,$PostNumber";
 

 
View user's profileSend private messageSend e-mailVisit poster's websiteMSN Messenger Reply with quote

mia_undertaker
Reputation: 447
Local time: 7:44 AM


Status: Offline
0.10 posts per day
Medals: 0

Joined: Jun 03, 2007
Last Visit: 10 Jun 2008
Posts: 38
Points: 628 

Post Help with code, new forum posts Posted: Sat May 03, 2008 10:08 am   

Shop Purchases:
Clan Roster v1.7 Php Nuke Module · Clan Roster 2.0

I think you could also use this:

Code:
$query = "SELECT *
        FROM nuke_bbposts, nuke_users, nuke_bbtopics, nuke_bbforums
        WHERE nuke_bbposts.topic_id=nuke_bbtopics.topic_id
        AND nuke_bbposts.forum_id=nuke_bbforums.forum_id
        AND nuke_bbposts.poster_id=nuke_users.user_id
      AND nuke_bbforums.forum_id!=7
        GROUP BY topic_last_post_id DESC LIMIT $PostNumber";


Then it will only give you one topic.

[MIA] UnderTaker
www.MIAClan.net
 

 
View user's profileSend private message Reply with quote




DreAdeDcoRpSE
Reputation: 632.7
votes: 3
Local time: 7:44 AM
Location: Back of your Mind
usa.gif

Status: Offline
0.97 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)
Forums Moderator
Forums Moderator
Joined: Sep 22, 2007
Last Visit: 05 Jul 2008
Posts: 279
Points: 3948 

View user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger Reply with quote

mia_undertaker
Reputation: 447
Local time: 7:44 AM


Status: Offline
0.10 posts per day
Medals: 0

Joined: Jun 03, 2007
Last Visit: 10 Jun 2008
Posts: 38
Points: 628 

View user's profileSend private message Reply with quote

DreAdeDcoRpSE
Reputation: 632.7
votes: 3
Local time: 7:44 AM
Location: Back of your Mind
usa.gif

Status: Offline
0.97 posts per day
Medals: 1 (View more...)
Site Supporter (Amount: 1)
Forums Moderator
Forums Moderator
Joined: Sep 22, 2007
Last Visit: 05 Jul 2008
Posts: 279
Points: 3948 

View user's profileSend private messageVisit poster's websiteAIM AddressYahoo MessengerMSN Messenger Reply with quote
Post new topic   Reply to topic  
   www.clan-themes.co.uk Forum Index » PHPBB


 
10 Replies / 429 Views
Page 1 of 1
All times are GMT
Display posts from previous: