Сортиране на Топици

Marik

Registered
Преди време инсталирах сортиране на топици мод , но нямам спомен кой беше , забелязвам че като сортирам примерно по име и то се сортира де , но като натисна 2 - ра страница и то отпада.

Може ли някой да ми помогне да го направя да се задържи на която и да е страница :?

Само кажете кои файлове ви трябват де.

Предполагам viewforum.php ще ви трябва.

Ето вижте при него в кое се съмнявам

Код:
if(isset($HTTP_POST_VARS['order']))
{
	$sort_order = ($HTTP_POST_VARS['order'] == "ASC") ? "ASC" : "DESC";
}
else if(isset($HTTP_GET_VARS['order']))
{
	$sort_order = ($HTTP_GET_VARS['order'] == "ASC") ? "ASC" : "DESC";
}
else
{
	$sort_order = "DESC";
}

if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode']))
{
	$mode = (isset($HTTP_POST_VARS['mode'])) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];

	switch($mode)
	{
		case 'topics':
			$order_by = "t.topic_title $sort_order";
			break;
		case 'replies':
			$order_by = "t.topic_replies $sort_order";
			break;
		case 'author':
			$order_by = "u.username $sort_order, p.post_username $sort_order";
			break;
		case 'views':
			$order_by = "t.topic_views $sort_order";
			break;
		case 'time':
			$order_by = "t.topic_id $sort_order";
			break;
		default:
			$order_by = "t.topic_last_post_id $sort_order";
			break;
	}
}
else
{
	$order_by = "t.topic_last_post_id DESC";
}

//
// Topics sorting
//
$mode_types_text = array($lang['Post_Normal'],$lang['Topics'],$lang['Date'],$lang['Replies'],$lang['Author'],$lang['Views']);
$mode_types = array("default", "topics", "time", "replies", "author", "views");

$select_sort_mode = "<select name=\"mode\">";
for($i = 0; $i < count($mode_types_text); $i++)
{
	$selected = ($mode == $mode_types[$i]) ? " selected=\"selected\"" : "";
	$select_sort_mode .= "<option value=\"" . $mode_types[$i] . "\"$selected>" . $mode_types_text[$i] . "</option>";
}
$select_sort_mode .= "</select>";

$select_sort_order = "<select name=\"order\">";
if($sort_order == "ASC")
{
	$select_sort_order .= "<option value=\"ASC\" selected=\"selected\">" . $lang['Sort_Ascending'] . "</option><option value=\"DESC\">" . $lang['Sort_Descending'] . "</option>";
}
else
{
	$select_sort_order .= "<option value=\"ASC\">" . $lang['Sort_Ascending'] . "</option><option value=\"DESC\" selected=\"selected\">" . $lang['Sort_Descending'] . "</option>";
}
$select_sort_order .= "</select>";

Код:
// on each viewforum page ...
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id 
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_last_post_id
		AND p.poster_id = u2.user_id
		AND t.topic_type = " . POST_ANNOUNCE . " 
	ORDER BY $order_by ";
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

$topic_rowset = array();
$total_announcements = 0;
while( $row = $db->sql_fetchrow($result) )
{
	$topic_rowset[] = $row;
	$total_announcements++;
}

$db->sql_freeresult($result);

//
// Grab all the basic data (all topics except announcements)
// for this forum
//
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time 
	FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
	WHERE t.forum_id = $forum_id
		AND t.topic_poster = u.user_id
		AND p.post_id = t.topic_first_post_id
		AND p2.post_id = t.topic_last_post_id
		AND u2.user_id = p2.poster_id 
		AND t.topic_type <> " . POST_ANNOUNCE . " 
		$limit_topics_time
ORDER BY t.topic_type DESC, $order_by 
	LIMIT $start, ".$board_config['topics_per_page'];
if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}

$total_topics = 0;
while( $row = $db->sql_fetchrow($result) )
{
	$topic_rowset[] = $row;
	$total_topics++;
}

$db->sql_freeresult($result);

//
// Total topics ...
//
$total_topics += $total_announcements;
 

Back
Горе