• Resolved molavem

    (@molavem)


    I’m not a very good with code, but I wanted to ask if the following plan of action is right for my objective, which is for my blog to have a special page that queries a database of, say, about 100 book titles, authors, etc.

    Here’s what I think I should do:

    1. Create custom tables at the wp database for the book collection.
    2. Create a function that queries the database and returns the result as $wpdb which I think is standard
    3. Make a new page template by saving index.php as bookfind.php
    4. Call the function from somewhere inside bookfind.php

    Is that correct? If so, I just wanted to ask a few questions to help nudge me in the right direction.

    1. How do I apply bookfind.php as a template so I can call it from the wordpress system?
    2. Would it be better to create a widget for this, so I can deploy it anywhere I like?
    3. Would creating a widget be easier than making a template?

    I know little PHP at the moment, as I’m more familiar with MySQL. I’m willing to do the research and grunt work and all that. But I would hate to spend weeks studying geology (so to speak), only to find out that it was geography I should have studied all along, if you get my drift.

    Cheers

Viewing 2 replies - 1 through 2 (of 2 total)
  • 1. Just create your template, then create a Page and assign that Template to that Page. Then use the Pages Widget to provide you navigation to your page.

    2 and 3 you could create a widget–you’d need to consider downloading and installing Otto’s PHP Code Widget, then put the code in one of those widgets.

    Even though you didn’t ask, are you sure you can’t use either posts or pages to create your book collection. Or use post types (which are very improved in the coming Version 3.0 (see http://wordpress.org/extend/plugins/gd-taxonomies-tools/ plugin for a 2.9.2 plugin that assists with post types).

    Thread Starter molavem

    (@molavem)

    These are enough suggestions for me to start moving forward. And the fact that somebody replied to my post implies that what I want to do is not impossible. Thanks, MichaelH.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Querying custom tables in the wp database and displaying results on a page’ is closed to new replies.