The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Getting Last 10 Posts but not including posts in staff forum
I am currently working on a homepage for my site which will get the latest posts and so on.
I have managed to select the most 10 recent posts from the vb_post table and display them, but I am struggling to make sure I do not display posts were the forum it is posted in is the staff forum Someone mentioned a JOIN but I have no idea what to do. Can anyone help? Thanks. |
#2
|
||||
|
||||
It would help if you posted the query you are using. If you are querying the post table, then you will probably have to join with the thread table on post.threadid = thread.threadid and then do AND thread.forumid <> xx (where xx is your staff forum). I can never figure out if its just a JOIN or a INNER JOIN or OUTER JOIN or LEFT JOIN or RIGHT JOIN of *whatever* JOIN, so hopefully someone else can come help after you post your query.
|
#3
|
|||
|
|||
Thanks for your help.
This is my query so far: $query = "SELECT * FROM vb_post WHERE visible = 1 ORDER BY postid DESC LIMIT 0, 10"; IF I change it to this: $query = "SELECT * FROM vb_post, vb_thread WHERE visible = 1 AND vb_post.threadid = vb_thread.threadid AND vb_thread.forumid <> 4 ORDER BY postid DESC LIMIT 0, 10"; I get the error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/thesno/public_html/getnews.php on line 22 --------------- Added [DATE]1226769124[/DATE] at [TIME]1226769124[/TIME] --------------- I did it! Not the best way do to it I'm sure would be grateful if someone could show a better way but this works: PHP Code:
|
#4
|
||||
|
||||
I was thinking of something more along this line:
Code:
$query = "SELECT * FROM vb_post INNER JOIN vb_thread AS thread ON(thread.threadid = post.threadid) WHERE visible = 1 AND thread.forumid <> xx ORDER BY postid DESC LIMIT 0, 10"; |
#5
|
|||
|
|||
When I use that I get the error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/thesno/public_html/index2.php on line 72 Anyone else got any ideaS? |
#6
|
||||
|
||||
What is your whole code if you use that line?
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|