Current location: Hot Scripts Forums » Programming Languages » PHP » Last Post Problem


Last Post Problem

Reply
  #1 (permalink)  
Old 05-03-05, 01:42 AM
DA Master DA Master is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Yorkshire
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Last Post Problem

I'm currently creating my custom forum system.

Everything is fine except when the last post comes into play. I have a query that selects the most recent row from the thread and post table. However I only want the most recent one from both. I feel this is a job for the JOIN stuff but have no idea on the query to use.

Thanks in advance
__________________
PHP Code:

<?php if(PHP_OS == 'Windows') { echo "Doh"; } ?>

Reply With Quote
  #2 (permalink)  
Old 05-03-05, 03:06 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
Code:
SELECT
   t.id, t.title, p.id, p.title
FROM
   posts AS p LEFT OUTER JOIN threads AS t
        ON t.id=p.thread_id
ORDER BY
   p.time
this a baisc one..
just replace the names with the one you have.
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 05-03-05, 07:22 AM
DA Master DA Master is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Yorkshire
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
I guess I replace t with the name of threads table and p with posts table. I'm confused about this though...

t.id=p.thread_id

is this thread.threadid=post.threadid or

thread.threadid=post.postid
__________________
PHP Code:

<?php if(PHP_OS == 'Windows') { echo "Doh"; } ?>

Reply With Quote
  #4 (permalink)  
Old 05-03-05, 08:32 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
it's thread.threadid=post.threadid
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #5 (permalink)  
Old 05-03-05, 09:04 AM
DA Master DA Master is offline
Wannabe Coder
 
Join Date: Jun 2003
Location: Yorkshire
Posts: 116
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by NeverMind
it's thread.threadid=post.threadid
Thanks, however shouldnt this be forumid? I'm dragging the last post in the whole forum not just one thread.
__________________
PHP Code:

<?php if(PHP_OS == 'Windows') { echo "Doh"; } ?>

Reply With Quote
  #6 (permalink)  
Old 05-03-05, 02:50 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
SELECT MAX(forumid) FROM forums
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM
deleting a post in access junkie_xl ASP 1 08-10-04 05:30 AM
Interesting Problem!!! ksroadrunner13 ASP 4 07-15-04 04:47 AM
Problem with CDONTS javadude2003 ASP 23 08-07-03 11:09 PM


All times are GMT -5. The time now is 06:43 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.