After almost a week, I have working code to pull a forum id from a select that is used in a query to list threads for that forum. The code works but is wild that I must wrap quotes around $forum_number at one part to get the query to run properly. PHP: $forum_number = $instance['show_forum_number']; $forum_number = " \"$forum_number\" "; $select_thread_qry = ' SELECT thread_id, title, node_id, discussion_state FROM `xf_thread` WHERE discussion_state = 1 AND node_id = ' . $forum_number . ' ORDER BY `thread_id` DESC LIMIT 50 '; $select_threads = XenForo_Application::get( 'db' )->fetchAll( $select_thread_qry ); Do you have any suggestions?