Log in

View Full Version : SQL Query Syntax


DrussRob
01-26-2008, 08:23 PM
I've tried to get this to exclude certain forums from the list by adding NOT IN (1, 2, 3); and hiding private with "visible".
But is doesnt seem to be working right, can anyone see what I've maybe done wrong?

thx:)

<?php
$threads = $db->query_read("
SELECT title, threadid FROM " . TABLE_PREFIX . "thread WHERE visible (<> 0) AND forumid (NOT IN (3, 4, 9))
LIMIT 0,6
");
while ($thread = $db->fetch_array($threads))
{
$title = $thread['title'];
$threadid = $thread['threadid'];

echo "<a href='forum/showthread.php?t=$threadid'>$title</a><br />";
}
?>

also does "visible" control restricted threads to different usergroup?

Lynne
01-26-2008, 09:10 PM
I believe the line would be (no added parenthesis):

SELECT title, threadid FROM " . TABLE_PREFIX . "thread WHERE visible <> 0 AND forumid NOT IN (3, 4, 9)

Try that and see if it works.

As for visible, I'm not sure, but I think it has to do with whether it is visible to anyone but the mods - meaning it is a moderated post and needs to be approved still.