<?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: Cannot output results of WPDB query to drop down list</title>
		<link>https://legacy.forums.gravityhelp.com/topic/cannot-output-results-of-wpdb-query-to-drop-down-list</link>
		<description>Gravity Support Forums Topic: Cannot output results of WPDB query to drop down list</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 09:20:32 +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/cannot-output-results-of-wpdb-query-to-drop-down-list" rel="self" type="application/rss+xml" />

		<item>
			<title>Chris Hajer on "Cannot output results of WPDB query to drop down list"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/cannot-output-results-of-wpdb-query-to-drop-down-list#post-160206</link>
			<pubDate>Mon, 04 Mar 2013 16:00:43 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">160206@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Right after line 14, can you dump the $sob array and see what is contains?  It's as if you have the correct number of items, but you're not referencing them correctly.  If you can &#34;print_r($sob)&#34; between line 14 and 15, you will see why blank values are being assigned for the option text and value.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>lindermyers on "Cannot output results of WPDB query to drop down list"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/cannot-output-results-of-wpdb-query-to-drop-down-list#post-156755</link>
			<pubDate>Thu, 28 Feb 2013 08:58:50 +0000</pubDate>
			<dc:creator>lindermyers</dc:creator>
			<guid isPermaLink="false">156755@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I have the following function to display values from a custom database table in a DDL.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;function DDL_Sob($form){
    //only populating drop down for form id 27 - Referral
    global $wpdb;
	if($form[&#38;quot;id&#38;quot;] != 27)
       return $form;

	$sql = &#38;quot;SELECT * FROM &#38;lt;code&#38;gt;bus_source&#38;lt;/code&#38;gt; ORDER BY name&#38;quot;;
	$sobs = $wpdb-&#38;gt;get_results($sql, ARRAY_N);

	//Creating drop down item array.
    $items = array();
    $items[] = array(&#38;quot;text&#38;quot; =&#38;gt; &#38;quot;&#38;quot;, &#38;quot;value&#38;quot; =&#38;gt; &#38;quot;&#38;quot;);

    foreach($sobs as $sob)
        {$items[] = array(&#38;quot;value&#38;quot; =&#38;gt; esc_attr($sob-&#38;gt;name), &#38;quot;text&#38;quot; =&#38;gt; esc_attr($sob-&#38;gt;name));}

    //Adding items to field id 15. Replace 15 with your actual field id. You can get the field id by looking at the input name in the markup.
    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field)
        if($field[&#38;quot;id&#38;quot;] == 15){
            $field[&#38;quot;choices&#38;quot;] = $items;
        }

    return $form;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;In mySQL the results are generated and in GF/WP the SELECT/OPTION statements are generated for each row but the values/text are empty as in:&#60;/p&#62;
&#60;p&#62;&#38;lt;select&#38;gt;&#60;br /&#62;
&#38;lt;option value&#38;gt;&#38;lt;/option&#38;gt;&#60;br /&#62;
&#38;lt;option value&#38;gt;&#38;lt;/option&#38;gt;&#60;br /&#62;
&#38;lt;option value&#38;gt;&#38;lt;/option&#38;gt;&#60;br /&#62;
&#38;lt;/select&#38;gt;&#60;/p&#62;
&#60;p&#62;Any suggestions as to what I've gotten wrong?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
