1

Topic: Change Order BY

Hello!

It is possible to change the ORDER BY (Descending) in the Posts. So, if ex. 100 users posted messages, the next on don't have to scroll down to read the newest post?

Cound anybody help me to change the source.

Kind regards
Mippo

Re: Change Order BY

Open up viewtopic.php and go to line 213. Replace:

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

with

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id LIMIT '.$start_from.','.$disp_posts.' DESC') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3

Re: Change Order BY

Sorry but it doesn't work.

Error:

An error was encountered
Error: Unable to fetch post info. 

Is it the line below this Comment?
// Retrieve the topic posts (and their respective poster)

Is this the value to change the order ?? $disp_posts.' DESC'

Kind regards
David

4

Re: Change Order BY

Perhaps in my version it isn't de same... I have the version 1.0.1.

Re: Change Order BY

Oh, my mistake. Replace it with

$result = $db->query('SELECT u.email, u.title, u.url, u.location, u.use_avatar, u.signature, u.email_setting, u.num_posts, u.status, u.registered, u.admin_note, p.id, p.poster, p.poster_id, p.poster_ip, p.poster_email, p.message, p.smilies, p.posted, p.edited, p.edited_by FROM '.$db->prefix.'posts AS p INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id WHERE p.topic_id='.$id.' ORDER BY p.id DESC LIMIT '.$start_from.','.$disp_posts) or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());

"Programming is like sex: one mistake and you have to support it for the rest of your life."

6

Re: Change Order BY

Thank you. It works.. smile

Re: Change Order BY

It works smile But when you have a topic than have more than 1 pages, if you click the main page to show the newest post, hte whole thing will show you the last page of the topic. Any idea to fiy it? I'm tired tonite to look into it. smile

Re: Change Order BY

That's gonna be a bit more complicated to fix. Perhaps you should stick to that topic in the mod requests forum after all :)

"Programming is like sex: one mistake and you have to support it for the rest of your life."