Have a look at this question for a fairly simple solution.
Basically, create a plugin to contain your code, add a rewrite rule to intercept any requests that match your custom url, and parse or pass whatever data they contain to your plugin, which can then use those variables to produce whatever output you need.
I also suggest using the wpdb class to do your database queries.
Related Posts:
- get_results using wpdb
- Count & Display Database Queries
- Export wordpress table to excel
- How best to inject ads between posts in the loop?
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Change all http to https in mysql databse?
- WooCommerce – Query for ordered products
- PHP variable in WordPress database query
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Query WordPress database by registered date and role
- How to fix unchanged URLs in Database after running serialized search and replace script?
- How to prevent WordPress from retrieving data for the last 10 posts in the database?
- Query from a different database than the default
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- Select Multiple meta_value from WP DB; Single Query
- CRUD operations using WordPress database API
- Critical error in final stage of website launch – URLs are BROKEN!
- Hook directly into query execution
- Advanced SELECT query with condtional statements
- Select two sums with single get_var statement
- Replace/Mute/Stop Search Query
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- wp search-replace (not executing)
- cache specific data?
- 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
- WordPress site URL changed; how to fix it without database access?
- Query multiple tables at once?
- $wpdb->query can’t insert data
- Custom WordPress Table wpdb
- Best practice to limit results in get_row()?
- Connecting to a different database
- SQL query to set posts in bulk based on the post content
- Query Column of Specific ID from Database Table
- Custom search query by category id
- How to display data from db in select list [closed]
- How can I query the db to access current post information?
- Compare User meta_value with Product meta_value
- How to insert a value to decimal type field using wpdb->prepare?
- Join Query on WP_USERMETA Table
- Insert NULL value using prepare()
- Job and Employee Performance Tracking with Product Safety
- WordPress Database Query works in phpMyAdmin but not in the code
- wpdb query to insert images in to post/page gallery
- Set SQL_BIG_SELECTS and MAX_JOIN_SIZE on a WP_Query
- Performance bug – slow DB query
- How to optimise this database query?
- How can we speed up wp_get_nav_menu_items()?
- Extracted CSV as Array for Custom Query Loop
- Should I Use only wpdb Class to Write Custom Queries?
- Generating an HTML table from an array based on dynamic key values
- Moving Site: Is Re-downloading Files After Changing URLs necessary?
- Pulling values from a sepcific row in table
- Using class id from array for query
- Update references to pictures on website after moving to new URL
- database search feature
- 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
- How do I find users by password?
- Display custom data based on URL slug
- How to resolve ORA-011033: ORACLE initialization or shutdown in progress
- Oracle SQL query for Date format
- Using wpdb to connect to a separate database
- Database connection close
- Importing posts from old website to new conflicting post ID’s?
- Exporting revisions
- How to use multiple database in wordpress?
- Is removing orphaned wp_postmeta records safe?
- What ALL can cause “Another update is currently in progress.”? [closed]
- Error connecting to DB in /wp-includes/wp-db.php on line 1538 [closed]
- Trigger Plugin database update after git pull
- Query string parameters from custom fields, inconsistent results
- SQL Error wp_commentmeta – incorrect table definition
- Change WordPress prefix for only one table?
- Two websites one database, administrator not working on second website
- How to get the SQL of the changes made to the database from an update or upgrade?
- How can i add custom fields into the contact form 7 [closed]
- WordPress and a secondary database?
- Remove empty rows from the database
- Check if post id exist in table than only update instead of inserting new row
- Detail explanation of wordpress database fields and metatag list [closed]
- After database migration, theme mods don’t show [closed]
- Remote database connection and local development
- Website displays old version of page
- A change in URL slug in database returns 404, how can I do auto-redirect?
- Displaying table data on a page
- muliple wordpress installs (network) on different databases
- Whats the best practise on how to store json data from a custom settings page?
- Recovery – Restore Database after moving folder location locally
- How to optimize wp_option table?
- Database for JQuery Autocomplete field
- Catchable fatal error in formatting.php
- Wrong url for the images while using same database for two WordPress installations
- Sending WordPress database information to cross domain the safe way?
- How can i maintain permalink structure and avoid a 404 error when loading external content?
- Attach posts based on category and position
- wp-config was suddenly updated
- Weird WP -Cli Error Connection Refused