WordPress.org

Ready to get started?Download WordPress

Forums

displaying custom database data on site (2 posts)

  1. jkmuller
    Member
    Posted 8 years ago #

    I have a table with data that I would like to display in various areas of my blog. I'm having difficulty with figuring out how to get the data from the mysql database to my site. I've tried creating a custom function in my theme file but I seem to get errors when I try and change the database. How can I get data from the database and be able to display it in posts and pages? Do I need to create custom functions to send my own queries?

  2. Seventi7
    Member
    Posted 8 years ago #

    After creating a table in the WordPress Database called "Custom"
    Write a function to this effect.

    // function CustomFunction($variable)
    // {
    // Global $wpdb; $Custom = $wpdb->get_row('
    // SELECT * FROM wp_custom WHERE fieldname = "'.$variable.'"
    // ');
    // echo $Custom->fieldname;
    // }

    This pull will read all fields into the $Custom variable array and each field name can be accesed as part of that array using $Custom->fieldname;

    To acces this functionality inside a post you will need a plugin do search on the forum for this.

Topic Closed

This topic has been closed to new replies.

About this Topic