WordPress.org

Support

Support » How-To and Troubleshooting » How to get information from a database

How to get information from a database

  • Hello,

    I really like WordPress and I would like to use it on my next project.

    Here it is:

    – We want to have a site with first page a search
    – Second page is the list of results from the search
    – Third page is the page for a specific database entry that is hosted on a different mysql db (more than 500,000 entries)
    – Fourth page is an error page

    I am not sure how to set that up through wordpress. I am scared to put all db entries on the wordpress install. That’s why it’s in a different DB.

    Any thoughts on how to make that work and make it SEO friendly?

    Thanks!

    JMT

Viewing 4 replies - 1 through 4 (of 4 total)
  • To access a database other than the WordPress database, you simply grant your WordPress Database ID SELECT access to your other database. Then you code your query like this in PHP:

    global $wpdb;
    $wpdb->select('ebc');
    $memberlist = $wpdb->get_results('SELECT * FROM people WHERE member ORDER BY namelast');
    $wpdb->select(DB_NAME);

    That last line is essential or WordPress will fail almost immediately after.

    Hello jonradio,

    Thanks for your reply.

    Ok so after granting access to the other database, how do I set up search to this other database? What about getting access to results?

    and when I access an entry, how can I customize the entry?

    I am still new to this and I want to make sure this is simple and efficient.

    Thanks for your help!

    JMT

    Probably best to start reading here:
    http://codex.wordpress.org/Class_Reference/wpdb

    Thanks a lot 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to get information from a database’ is closed to new replies.
Skip to toolbar