PDA

View Full Version : need a little help with member.php


Mutt
12-01-2001, 02:47 PM
I could use a little help. I'm playing around with member.php to change a the profile page. I'd like to list the last 10-20 posts made by a member instead of just the last one. I'm only changing the 'get last post' section. The following code works and you just need to stick $TheLastPosts into the getinfo template to display the list. Here's the problem. If you made several posts in one thread, you'll have several links to differnet parts of the same thread. once a thread is listed, I don't want it to be listed again. I've been trying to find a simple way to weed out the dups, but nothing is working out perfect. Help me out guys. :) thanks


// get last posts
$totalposts=$userinfo[posts];
if ($userinfo[posts]!=0 and $userinfo[lastpost]!=0) {
$lastpostdate=vbdate($dateformat,$userinfo[lastpost]);
$lastposttime=vbdate($timeformat,$userinfo[lastpost]);
$getlastposts=$DB_site->query("SELECT thread.threadid,thread.title,thread.forumid,postid ,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND thread.visible = 1 AND post.userid='$userid' ORDER BY post.dateline DESC LIMIT 20");
while ($getlastpost=$DB_site->fetch_array($getlastposts)) {
$getperms=getpermissions($getlastpost[forumid]);
if ($getperms[canview]) {
$theposttitle=$getlastpost[title];
$thepostdate=vbdate($dateformat,$getlastpost[dateline]);
$lastposttime=vbdate($timeformat,$getlastpost[dateline]);
$theposturl="showthread.php?s=$session[sessionhash]&postid=$getlastpost[postid]#post$getlastpost[postid]";
$TheLastPosts.="<a href=\"$theposturl\">$theposttitle</a> : $thepostdate $lastposttime<br>";
}
}
} else {
$lastpostdate="Never";
}

Admin
12-01-2001, 02:58 PM
Use GROUP BY:
SELECT thread.threadid,thread.title,thread.forumid,postid ,post.dateline FROM post,thread WHERE thread.threadid=post.threadid AND thread.visible = 1 AND post.userid='$userid' GROUP BY thread.threadid ORDER BY post.dateline DESC LIMIT 20

Mutt
12-01-2001, 05:57 PM
wow, that was quick

thanks so much. that did the trick.