Re: Getting forum page number
get_var only gets one item – the first and only.
get_results which returns an array.
Actually, even better in this case would be
get_col which should return a flat array.
Another trick to use on that query is possibly to include the topic_time as the end in the WHERE clause so that it doesn’t bother to pull up 10,000 topic id’s if the topic you are looking for is in the first 100
$query="SELECT topic_id FROM $bbdb->topics WHERE forum_id=$forum_id and topic_time<=$topic->topic_time ORDER BY topic_time DESC";
$topic_array = $bbdb->get_col($query);
We could take a huge shortcut and a bit of a gamble that no other topic has the same exact topic_time as this one and simply get the position via count, assuming it’s the very last one. Occasionally you might be a page short, or a page too many.
$query="SELECT count(topic_id) as position FROM $bbdb->topics WHERE forum_id=$forum_id and topic_time<=$topic->topic_time ORDER BY topic_time DESC";
$position = $bbdb->get_var($query);
Then you divide position by topics per page and you have the page it’s on.