How do I insert content of various MySQL fields in post?

I also would vote for creating a short code. The shortcode code could pull data from a database/table, and ‘build’ the text you want with values from the table. Lots of googles on how to build shortcodes – check those out, vs me putting some sample code here. You would put the shortcode function in … Read more

Form display in new page

Try to create a new page and put [elh-db-insert] as content. If you want to use [insert-into-db] as your shorcode, you should change add_shortcode(‘elh-db-insert’, ‘elh_insert_into_db’); to add_shortcode(‘insert-into-db’, ‘elh_insert_into_db’);

How to get specific table by current user login

Note that you may need to use WPDB::prepare() to prevent against SQL injections. Although, it might be arguable in your specific case… // If the query does not work, ensure the table name is correct… $table = $wpdb->prefix . ‘SaveContactForm7_1’; $reservations = $wpdb->get_results( $wpdb->prepare( “SELECT * FROM $table WHERE user = %s”, $username ) ); … Read more

Performance bug – slow DB query

It is relatively rare for WP to have query performance issues on a small to moderately sized site: The queries it typically runs are reasonable (not perfect, but reasonable). A lot of things queried are aggressively cached within page load, and persistently with object cache available. While you certainly can throw enough code at it … Read more