hello everyone, this is my function...
my problem is here: "".get_option('wpbb_bbprefix')."topics WHERE forum_id = 1 AND........"
This is obviously pulling all the topics in forum_id 1 limited to 2 results. What I want is for it to pull 2 of the forum topics in each forum_id...
the first code is pulling a list of all the forums
the second code is pulling the topics, in the topic code I want it to pull the 2 topics associated with the forum that was pulled in the previous code...
I was thinking I would have to define some type of variable in the first code to set the forum_id to global_forum_id and then put forum_id = global_forum_id in the second code? or combine the two codes into once piece of code?
Either way... I'm having trouble and just thinking out loud, hope you can help.
ex:
forum1
-forum1 topic 1
-forum1 topic 2
forum2
-forum2 topic 1
-forum2 topic 2
etc...
function wp_bb_get_discuss_test() {
global $table_prefix,$wpdb;
$forum_slimit = get_option('wpbb_limit');
if (get_option('wpbb_exdb')) {
$exbbdb = new wpdb(get_option('wpbb_dbuser'), get_option('wpbb_dbpass'), get_option('wpbb_dbname'), get_option('wpbb_dbhost'));
$bbforum_test = $exbbdb->get_results("SELECT FROM ".get_option('wpbb_bbprefix')."forums WHERE forum_parent = 0 ORDER BY forum_order");
}
else {
$bbforum_test = $wpdb->get_results("SELECT FROM ".get_option('wpbb_bbprefix')."forums WHERE forum_parent = 0 ORDER BY forum_order");
}
if ($bbforum_test) {
echo '
<div id="discussions">
<table id="latest">
';
foreach ( $bbforum_test as $bbforum_test ) {
$forum_text = wpbb_trim($bbforum_test->forum_name, get_option('wpbb_slimit'));
echo "
<tr class=\"alt\">
";
if (get_option('wpbb_permalink')) {
echo '<td><a href="' . get_option('wpbb_path') . '/topic/' . $bbforum->forum_id . '"><h3>' . ("$forum_text") . '</h3></a></td>';
}
else {
echo '<td><a href="' . get_option('wpbb_path') . '/forum.php?id=' . $bbforum_test->forum_id . '"><h3>' . ("$forum_text") . '</h3></a></td>';
}
echo "
</tr>
";
if (get_option('wpbb_exdb')) {
$exbbdb = new wpdb(get_option('wpbb_dbuser'), get_option('wpbb_dbpass'), get_option('wpbb_dbname'), get_option('wpbb_dbhost'));
$bbtopic = $exbbdb->get_results("SELECT FROM ".get_option('wpbb_bbprefix')."topics WHERE forum_id = 1 AND topic_status = 0 ORDER BY topic_time DESC LIMIT 2");
}
else {
$bbtopic = $wpdb->get_results("SELECT FROM ".get_option('wpbb_bbprefix')."topics WHERE forum_id = 1 AND topic_status = 0 ORDER BY topic_time DESC LIMIT 2");
}
foreach ( $bbtopic as $bbtopic ) {
$title_text = wpbb_trim($bbtopic->topic_title, get_option('wpbb_slimit'));
echo "
<tr class=\"alt\">
";
if (get_option('wpbb_permalink')) {
echo '<td><a href="' . get_option('wpbb_path') . '/topic/' . $bbtopic->topic_id . '">-' . __("$title_text") . '</a></td>';
}
else {
echo '<td><a href="' . get_option('wpbb_path') . '/topic.php?id=' . $bbtopic->topic_id . '">-' . __("$title_text") . '</a></td>';
}
echo "
</tr>
";
}
}
echo "</table></div>";
}
}