PDA

View Full Version : Last Post Minute Query


Boofo
05-11-2003, 12:35 PM
Logician, is there an easy way to pull out the last poster in your query for the last post minute hack? If I can do it through there, I can cut another query and have it give me the right result all at the same time. ;)

Logician
05-11-2003, 05:08 PM
I believe if changing the query to this should help:

SELECT post.dateline AS lastpostminute, thread.threadid, user.username
FROM post, thread
LEFT JOIN user ON user.userid = post.userid
WHERE thread.forumid = $forumid AND thread.threadid = post.threadid
ORDER BY post.dateline DESC
LIMIT 1

Then you can use variable $lastpostminDB[username]

Boofo
05-11-2003, 05:23 PM
LOL I just did this about 5 minutes ago. Here is the code I used and it seems to work.

$lastpostminDB=$DB_site->query_first("SELECT post.dateline as thread.threadid, username, userid FROM post,thread WHERE thread.forumid=$forumid AND thread.threadid=post.threadid ORDER BY post.dateline DESC LIMIT 1");

I use $lastpostminDB[username] for the last poster and $lastpostminDB[userid] for the link to the member's profile.

Will this code work or am I just lucky right now and it will mess up later? ;)

Logician
05-11-2003, 05:51 PM
I say go with my code (if it is working, I didn't test it!). For some reason getting the username from thread/post tables sometimes not works. This is why I put the left join query in my code to get it from the user table.

Boofo
05-11-2003, 05:57 PM
Thank you, sir. I'll go test it now and report back. ;)

Boofo
05-11-2003, 06:01 PM
Ok, tested and got no errors. How do I call the userid for the link to the user's profile now? I have been trying everything and can't find anything to work. ;)

Logician
05-11-2003, 08:19 PM
SELECT post.dateline AS lastpostminute, thread.threadid, user.username, user.userid
FROM post, thread
LEFT JOIN user ON user.userid = post.userid
WHERE thread.forumid = $forumid AND thread.threadid = post.threadid
ORDER BY post.dateline DESC
LIMIT 1

Boofo
05-11-2003, 08:50 PM
Thank you, again, sir. I guess I still don't have the hang of these queries, yet. ;)