<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Populate Drop Down dynamically by database Query - Solution.</title>
		<link>https://legacy.forums.gravityhelp.com/topic/populate-drop-down-dynamically-by-database-query-solution</link>
		<description>Gravity Support Forums Topic: Populate Drop Down dynamically by database Query - Solution.</description>
		<language>en-US</language>
		<pubDate>Tue, 21 Apr 2026 14:23:39 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/populate-drop-down-dynamically-by-database-query-solution" rel="self" type="application/rss+xml" />

		<item>
			<title>Rob Harrell on "Populate Drop Down dynamically by database Query - Solution."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/populate-drop-down-dynamically-by-database-query-solution#post-349763</link>
			<pubDate>Fri, 28 Jun 2013 08:20:17 +0000</pubDate>
			<dc:creator>Rob Harrell</dc:creator>
			<guid isPermaLink="false">349763@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Solutions are def. allowed here, thanks for posting!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gtm1ldy on "Populate Drop Down dynamically by database Query - Solution."</title>
			<link>https://legacy.forums.gravityhelp.com/topic/populate-drop-down-dynamically-by-database-query-solution#post-346329</link>
			<pubDate>Wed, 26 Jun 2013 17:05:30 +0000</pubDate>
			<dc:creator>gtm1ldy</dc:creator>
			<guid isPermaLink="false">346329@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;If you create a simple form with a single dropdown and want to populate it with a database table that contains all 50 states, Copy and paste the code below, replace the Form ID number and tables.  It will work.  Hope solutions are allowed here.&#60;/p&#62;
&#60;p&#62;add_filter(&#34;gform_pre_render_5&#34;, populate_dropdown); //5 is the GF Form ID&#60;br /&#62;
add_filter(&#34;gform_admin_pre_render_5&#34;, populate_dropdown);&#60;/p&#62;
&#60;p&#62;function populate_dropdown($form){&#60;br /&#62;
        global $wpdb; //Accessing WP Database (non-WP Table) use code below.&#60;br /&#62;
        $results = $wpdb-&#38;gt;get_results(&#34;SELECT btc_state_short from btc_state_list&#34;);&#60;/p&#62;
&#60;p&#62;        $choices = array();&#60;br /&#62;
        $choices[] = array(&#34;text&#34; =&#38;gt; &#34;Select a State&#34;, &#34;value&#34; =&#38;gt; &#34;&#34;); //adding a array option with no value, this will make the user select and option.&#60;/p&#62;
&#60;p&#62;foreach ($results as $result) {&#60;br /&#62;
                $choices[] = array(&#34;text&#34; =&#38;gt; $result-&#38;gt;btc_state_short, &#34;value&#34; =&#38;gt; $result-&#38;gt;btc_state_short);&#60;br /&#62;
        }&#60;/p&#62;
&#60;p&#62;    foreach($form[&#34;fields&#34;] as &#38;amp;$field){&#60;br /&#62;
        if($field[&#34;id&#34;] == 1){&#60;br /&#62;
            $field[&#34;choices&#34;] = $choices;&#60;br /&#62;
        }&#60;br /&#62;
    }&#60;/p&#62;
&#60;p&#62;    return $form;&#60;br /&#62;
}
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
