• Dear All,

    how can i display database results at a wordpress page.
    The database connection code is within a php file which should be executed also
    in WordPress. How can i implement the php code in wordpress to display
    the results from the mysql database query.

    In the php file it works fine but i don’t know how to integrate it
    to a wordpress page.

    Can anybody help me in this case?

    Best Regards
    Matthew

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey!

    You shouldn’t use a php file outside the scope of WordPress to handle data, as this is considered bad practice. I would suggest converting your php file to a plugin (Plugin Handbook: https://developer.ww.wp.xz.cn/plugins/) and using wpdb() to access your data (Codex: https://codex.ww.wp.xz.cn/Class_Reference/wpdb).

    I hope this helps?

    Cheers

    • This reply was modified 9 years, 4 months ago by 5k9m.
    • This reply was modified 9 years, 4 months ago by 5k9m.
    Moderator bcworkz

    (@bcworkz)

    5k9m suggests a good approach. For the sake of presenting alternatives, consider creating a custom page template. You mentioned integrating into a WP page, so this might be the right solution for you. While page templates can be managed with a plugin, they are really a theme based solution. This means you probably would want to create a child theme to protect your custom work from theme updates.

    Thread Starter wp2017

    (@wp2017)

    Dear 5k9m and bcworkz,

    sorry for the late reply.
    I took some days off.
    Your suggestions are very helpful.
    Many thanks for it.

    Best regards
    Matthew

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Display Results from Database Query in WordPress’ is closed to new replies.