You’re recreating the select element on every iteration through the loop, and you need to name your current loop assignment variable differently, as you’re overwriting your original.
Lastly, you’re also not assigning a value to the options within the loop, so you’re not going to get anything on the form submission, and text isn’t a valid type for a select element.
Try this:
global $wpdb;
$results = $wpdb->get_results ("SELECT adres FROM wp_ow_adres;");
echo '<td><select id="adres" name="adres">';
echo '<option value="">Select your address</option>';
foreach ( $results as $result ) {
echo '<option>'.$result->adres.'</option>';
}
echo </select></td>';
FYI, this is technically off topic for this site as it’s a php issue rather than a WordPress one, it just happens in the “context” of WordPress.
Related Posts:
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Query WordPress database by registered date and role
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- SQL query to set posts in bulk based on the post content
- Job and Employee Performance Tracking with Product Safety
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- SQL query to rewrite all media URLs to end with .webp
- Oracle SQL query for Date format
- WPDB Insert or if exists Update
- get_results using wpdb
- Count & Display Database Queries
- Display data from a non wordpress database on a page template
- Organizing WP Pages based on old website database
- Export wordpress table to excel
- Bulk Update of Custom Post Type Post Status through SQL
- How do I add indexes to WordPress Database?
- How best to inject ads between posts in the loop?
- WooCommerce – Query for ordered products
- PHP variable in WordPress database query
- Block search SQL from happening
- wpdb query on custom table not working [closed]
- How to execute mulitple statement SQL queries using $wpdb->query?
- Using table lock with wp_insert_post?
- Size article thumbnails and retrieve them directly from database
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Select Multiple meta_value from WP DB; Single Query
- wpdb_prepare with multiple or condition
- SQL Error wp_commentmeta – incorrect table definition
- CRUD operations using WordPress database API
- WordPress and MySQL: how to transfer Meta_key and Meta_Value from one post_id to another
- Hook directly into query execution
- How do I get the posts within a certain year/date(with sql query)?
- Select two sums with single get_var statement
- WordPress is not creating table in database after activating plugin,
- Difficulty importing my live site to local
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- Create table from array with prepare
- Setup private content for specific users with daily updates [closed]
- How Can I Put Meta_Compare in the Database-Query?
- Historic WordPress database connection
- Check if an option exists and get its value in one hit
- Which data is written and stored in the database when read-only (non-posting, non-commenting) users visit the site?
- WPDB SQL query with prepare() returning variable, not db value
- Query multiple tables at once?
- Problems with moving my WordPress site to another domain/server
- Is it possible to query from external database? [duplicate]
- $wpdb->query can’t insert data
- Custom WordPress Table wpdb
- Why this query is not showing any result on wordpresss home page?
- Is it possible to have more than 1 MySQL database in my WordPress blog?
- Best practice to limit results in get_row()?
- How to migrate a database from a server to another
- How to display content from external db with relevant urls
- Is my way to change WordPress server is correct?
- Delete/Replace words from X to Y in post content
- How to delete a particular row in a database table
- Delete all posts that do NOT have a specific tag
- Location of WP default mySQL tables creation file?
- Custom search query by category id
- Getting value from database table depending on field value
- custom tables in wordpress Database? (can i just create them with sql?)
- Compare User meta_value with Product meta_value
- Accidently changed the GUID
- DB prefix not updating
- How to insert a value to decimal type field using wpdb->prepare?
- Sql query to get all metadata for a post
- Join Query on WP_USERMETA Table
- I wanted to Know that how can I give ingore to 0000-00-00 in my config file
- SQL database import #1046 error
- How do I loop/iterate through posts to edit all img tags?
- Help posting values to DB on submit using $wpdb->query
- Is there a way for two deferent themes to consume two different DB on a same WP instance?
- wpdb query to insert images in to post/page gallery
- How to set posts to draft in bulk based on the content of the post
- How to create index (sql) to a meta_key?
- Set SQL_BIG_SELECTS and MAX_JOIN_SIZE on a WP_Query
- 2 $wpdb queries causing error Table ‘wp_postmeta’ is specified twice, both as a target for ‘UPDATE’
- Correct and secure way to access a custom SQL database in a custom PHP template file
- Performance bug – slow DB query
- How to get specific table by current user login
- The MySQL Connection could not be established., before it was joomla but i have change it into worpress
- How to optimise this database query?
- How to retrieve user data based on role using SQL?
- How can we speed up wp_get_nav_menu_items()?
- $wpdb not working
- Extracted CSV as Array for Custom Query Loop
- WordPress character set issue
- Should I Use only wpdb Class to Write Custom Queries?
- Generating an HTML table from an array based on dynamic key values
- Link wordpress with a SQl + MongoDB + .NET
- Pulling values from a sepcific row in table
- Using class id from array for query
- Getting deleted users in database
- Migrated to Namecheap, now Trouble with Database & wp-config [closed]
- export individual posts to text files or a single csv file
- SQL query : Select a thumbnail for a media
- How do I find users by password?
- Weird WP -Cli Error Connection Refused
- Change permalinks in posts via SQL