ForumsProgramming ForumPHP/MySQL - Data Re-crunching

0 2396
3,830 posts

Hi. I have a small problem with my (self-made, in the works) forum software, mostly how I manipulate it to display. It works a bit like these forums with the forum front page mechanics, with the forum id with threads and last post direction and posts and views and all that fun stuff. My main problem is when I try to implement a workaround for users who are mass-ignored (or ignored in general) by the community. I have it set so that when you post, it will update the front page as well with its id. When it's displayed, it will seek out the thread and all relevant data from the related tables. That's alright, but when I want to keep the information in-line when someone ignored posts, I run into problems.

See, the users are marked by their profiles (in a table) themselves through a simple binary switch. When I'm collecting the data and they're ignored, I have to work massively around to make sure that the data presented is correct and doesn't interrupt the flow of the program. Most of the problem is in a forum page in itself, because all recent threads and time stamps and authors must be checked and somehow must come out in-line. Not to mention, I don't even know if the code I am using works, since it's purely experimental that I saw people using and I can't run it since there's already forums running on my subdomain. Here's an example of the code.

$query = "SELECT * FROM threads WHERE forumid='{$forumid}' AND BIT(deleted)=1 AND (lastpost=posts.postid AND posts.userid=userbase.userid AND BIT(userbase.phantom)=0) ORDER BY lastposttime DESC";

Looking at the code, it might be relatively easy to guess what's what. However, this wouldn't work how I would want it to. Somehow I have to reorder the entire lists of threads based on whether or not the last post author is 'hantom'd' or not, and somehow I have to find the previous post from that thread and display it instead, depending on whether or not they are phantom'd as well. I'm thinking I might be able to just do that within the display loop itself, since it is just finding relevant data and displaying it rather than setting a query. In the example, however, those who are phantom'd just don't show up. I suppose my question is, is it possible to have a sort of conditional within the 'ORDER BY' sort so that I can differentiate the last posts, or is there a better way to deal with this?

  • 0 Replies
Showing 1-0 of 0