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
- What is “Advanced” SQL?
- Oracle SQL query for Date format
- WPDB Insert or if exists Update
- get_results using wpdb
- Count & Display Database Queries
- Where are image paths to product category images stored in WordPress database
- Sharing database for collaborative development
- Display data from a non wordpress database on a page template
- Organizing WP Pages based on old website database
- Export wordpress table to excel
- Inserting Post Meta From SQL
- Bulk Update of Custom Post Type Post Status through SQL
- How do I add indexes to WordPress Database?
- Moving an entire wordpress site from one domain to a new domain and database
- How best to inject ads between posts in the loop?
- Change all http to https in mysql databse?
- 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?
- Scheduling posts in database
- Size article thumbnails and retrieve them directly from database
- How to prevent WordPress from retrieving data for the last 10 posts in the database?
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Query from a different database than the default
- Select Multiple meta_value from WP DB; Single Query
- wpdb_prepare with multiple or condition
- Uppercase to sentence case for post titles
- 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)?
- Advanced SELECT query with condtional statements
- Select two sums with single get_var statement
- Export / import WordPress database
- WordPress is not creating table in database after activating plugin,
- Bulk-create posts from SQL database
- Difficulty importing my live site to local
- Replace/Mute/Stop Search Query
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- WordPress Database Huge wp_usermeta Table
- Create table from array with prepare
- cache specific data?
- Setup private content for specific users with daily updates [closed]
- How Can I Put Meta_Compare in the Database-Query?
- How to paginate information obtained from a query to a custom table?
- 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?
- Insert Query not working in the form
- 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()?
- pull data from a remote wordpress database
- How to migrate a database from a server to another
- How to display content from external db with relevant urls
- Clear Terms from Taxonomy for Specific Post IDs?
- Is my way to change WordPress server is correct?
- Why does changing Database Table Prefixes result in loss of content?
- Connecting to a different database
- Options on how to Display member specific data from a MS SQL database
- Delete/Replace words from X to Y in post content
- Query Column of Specific ID from Database Table
- 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
- $wpdb->get_var – What value is returned when zero records are found?
- WordPress SQL – How to Check for Category?
- Getting value from database table depending on field value
- How can I query the db to access current post information?
- 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
- Deleting empty meta key values
- 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
- Insert NULL value using prepare()
- 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?