MyBB Community Forums

Full Version: How do I select specific threads in a marquee?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
So far I have been using a marquee to display the latest threads from either all forums or from a specific forum as explained earlier by DennisTT and Zaher1988 in these threads: http://community.mybboard.net/showthread.php?tid=14731 & http://community.mybboard.net/showthread.php?tid=16642. Now, I have another question: how do I select specific threads from selected forums. In other words, how do I add more than one "tid" to the following:
$query = $db->query("SELECT tid, subject, lastposter, lastposteruid FROM ".TABLE_PREFIX."threads WHERE tid='X' ORDER BY lastpost DESC LIMIT 0, 5"); 
Thanks for your help in advance.

Regards
maatty
$query = $db->query("SELECT tid, subject, lastposter, lastposteruid FROM ".TABLE_PREFIX."threads WHERE tid IN(X,Y,Z) ORDER BY lastpost DESC LIMIT 0, 5");

Try that
Tikitiki Wrote:
$query = $db->query("SELECT tid, subject, lastposter, lastposteruid FROM ".TABLE_PREFIX."threads WHERE tid IN(X,Y,Z) ORDER BY lastpost DESC LIMIT 0, 5");

Try that

I've just tried it and got this error:

MySQL error: 1064
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN(1,2) ORDER BY dateline DESC LIMIT 0, 10' at line 1
Query: SELECT * FROM mybb_threads WHERE IN(1,2) ORDER BY dateline DESC LIMIT 0, 10
Can you post your PHP code for that?
DennisTT Wrote:Can you post your PHP code for that?

Actually there was a missing part in the code I used at first; but when I tried it again it works perfectly fine now with the code suggested bu Tikitiki:

  $query = $db->query("SELECT tid, subject, lastposter, lastposteruid FROM ".TABLE_PREFIX."threads WHERE tid IN(1,2,3,4) ORDER BY lastpost DESC LIMIT 0, 5");
Thanks a lot Tikitiki and many thanks for your concern my dear DennisTT.

Best regards