Jump to content

Recommended Posts

hello everyone, this is my function...

 

WHERE forum_id = 1 limit 2(i changed this for forum_id=1 just to make it not error)

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... WHERE forum_id = forum_id doesn't seem to pull the right thing.

 

ex:

forum1

-forum1 topic 1

-forum1 topic 2

forum2

-forum2 topic 1

-forum2 topic 2

etc...

 

how would I do that?

 

 

 

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>";
}
}

that makes sense, thanks for the help.  the code is long, but i believe all of it would be required to help.

 

 

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>";
   }
} 

hi guys, let me try again.  can anyone help me change this from pulling forum_id=1 to pulling forum_id=forum_id of the forum pulling in the previous get_results  Thanks!!

 

   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");
   }

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.