tomwi Posted December 16, 2008 Share Posted December 16, 2008 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>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/137138-how-to-pull-the-right-data-in-my-function/ Share on other sites More sharing options...
tomwi Posted December 17, 2008 Author Share Posted December 17, 2008 anyone help on this, or at least tell me why no responses? was it a dumb question? Quote Link to comment https://forums.phpfreaks.com/topic/137138-how-to-pull-the-right-data-in-my-function/#findComment-718032 Share on other sites More sharing options...
premiso Posted December 17, 2008 Share Posted December 17, 2008 I won't respond due to the lack of [ code] [ /code] tags (without the initial space) surrounding the code. Quote Link to comment https://forums.phpfreaks.com/topic/137138-how-to-pull-the-right-data-in-my-function/#findComment-718033 Share on other sites More sharing options...
genericnumber1 Posted December 17, 2008 Share Posted December 17, 2008 I, on principle, skip question involving large amounts of code, especially if it's not between code/php tags because I know the person hasn't read the forum rules. Quote Link to comment https://forums.phpfreaks.com/topic/137138-how-to-pull-the-right-data-in-my-function/#findComment-718034 Share on other sites More sharing options...
tomwi Posted December 17, 2008 Author Share Posted December 17, 2008 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>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/137138-how-to-pull-the-right-data-in-my-function/#findComment-718084 Share on other sites More sharing options...
tomwi Posted December 18, 2008 Author Share Posted December 18, 2008 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"); } Quote Link to comment https://forums.phpfreaks.com/topic/137138-how-to-pull-the-right-data-in-my-function/#findComment-719129 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.