I multiple forms on various pages of a WordPress site that all have the same drop down menu. Rather than update all the values in every select each time they change, I have created a table in my WordPress database that is populated with the source names. I am attempting to use PHP in the WordPress pages in order to display the drop down, but am encountering issues. Below is the code I am using for the drop down within the HTML form on the various pages.
<?php
echo "<select id=\"source\" style=\"max-width: 165px;\" name=\"source\">";
echo "<option value=\"\">Please select...</option>";
global $wpdb;
$wp_source = $wpdb->get_results("SELECT * FROM wp_source;");
foreach($wp_source as $table){
echo "<option value=\"" . $table->name . "\">" . $table->name . "</option>";
}
echo "<option id=\"other\" value=\"other\">Other</option>";
echo "</select>";
?>
The table name is wp_source and I am using a Plugin named Exec-PHP which allows a user to utilize PHP within WordPress posts/pages/widgets/etc. What I am seeing in my drop down is the following text: name."\">".$table->name." Any assistance you might offer would be greatly appreciated.
var_dump($wp_source)give you? - BizzyBobecho. I just want to see what the structure of the$wp_sourceoutput is. - BizzyBob