Jump to content

Recommended Posts

Hi,

I'm trying to display recent forum topics on a homepage. But what if I want to hide topics from more than one forum?

[code]
$forum = mysql_query('SELECT title, tid FROM ibf_topics WHERE forum_id!= 53 ORDER BY last_post DESC LIMIT 0, 1');
[/code]

The above code hides any posts from one of the moderator-only forums, but there are more than one, and I need to hide them all.

The other forums I need to hide are: 85, 86, 88, 90, 93

How can I hide all of these? I've been looking around for a solution for ages, but can't find anything. My guess is that it's pretty straightforward, and I'm just missing something. XD

Many thanks~!
Link to comment
https://forums.phpfreaks.com/topic/25866-more-than-one-attribute-for-where/
Share on other sites

I understand that.  The question I'm asking is how does your program know which IDs are the ones to hide?

You can use this MySQL statement:
SELECT title, tid FROM ibf_topics WHERE forum_id != 53 AND forum_id != 85 AND forum_id != 86

And so on.

Or you can use:
'SELECT title, tid FROM ibf_topics WHERE forum_id NOT IN(53, 85, 86, 88, 90, 93)

But my question is how does your program know to use 53, 85, 86, 88, 90, and 93?
How does it know that 33 should or should not be hidden?
Thanks for your help Roopurt.

I'm not sure I understand your question, however.

Each topic is a row in that table, and it's just selecting everything but 53 (with the != not equal to), so it just returns every other topic (including 33).

Sorry if I haven't got your question, but I'm still very new to PHP (and also it's 3:30 AM XD), but your help is exactly what I was looking for. Thank you very much :)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.