Jump to content

Recommended Posts

Hey,

I've been creating my own forum. It was going really well,

Until i realised I needed to set all threads with NEW replies,

to be shown above any recently posted threads. And I thought

making an SQL table, which stores the THREAD ID, and USER

when they have viewed the thread.

 

Well, i then had to make a syntax to paginate all my threads.

and then this is where my error occours...

 

My code:

$sql_threads = mysql_query("SELECT `subject`,`views`,`replies`,`closed`, 
		   CASE WHEN `thread_id` IN ($thread_id) THEN 1 
		   ELSE 2 END as `threadsort` 
		   FROM `bb_threads` 
		   WHERE `forum_id`='".$forum['forum_id']."' 
		   ORDER BY `threadsort`,`started_on` ASC 
	  	   LIMIT $limitvalue, $limit
	  	   ") or die("MySQL Error: ".mysql_error());

 

Mysql Error: picks up on line 2. which is

CASE WHEN `thread_id` IN ($thread_id) THEN 1

 

Does any one know How i could get around this error, using a simelar method.

Or is there a different way of knowing if a USER has viewed the topics with recent replies...

 

It's hard to express what i'm actually trying to do. sorry.

Link to comment
https://forums.phpfreaks.com/topic/54623-solved-problem-with-sql-syntax/
Share on other sites

Nope, I have the pagination.

The problem is putting threads with NEW posts/replies, above all new threads.

 

Say someone posted a thread 2 years ago, and theres been 100's since, then

someone replies to that thread 2 years ago, i want that to be placed ABOVE

the threads which have been posted to the recent day (for example today)

 

And i can only do it, but getting the thread ID's by a certain user (in seperate table)

then imploding the thread ID's, and thats where my error is.

line 2

Nope, that's not what my queries about.

Because the CASE clause. is arranging what i need.

 

But i need to get my IMPLODED id's into that query and run them correctly.

 

which is why i use CASE.

 

because the ORDER BY will order the Topics with new replies first,

then everything else after it, and both are arranged in DATE order.

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.