• I’m trying to get a mysql field value inside the post loop, however I can’t figure out how to do it as it gives me errors:

    <?php
    $threadtitle = the_title();
    $threadid = $wpdb->get_var(SELECT id wp_forum_threads WHERE subject = $threadtitle);
    echo ‘$threadid’;
    ?>

    Basically what I am trying to do is get the ID value from wp_forum_threads where subject is equal to the blog entry title. However I can’t figure out why that query wouldn’t work.

Viewing 1 replies (of 1 total)
  • Thread Starter djsap

    (@djsap)

    I seem to have forgotten the FROM in my query, but it still doesn’t work when I add it.

    <?php
    $threadtitle = the_title();
    $threadid = $wpdb->get_var(SELECT id FROM wp_forum_threads WHERE subject = $threadtitle);
    echo ‘$threadid’;
    ?>

Viewing 1 replies (of 1 total)

The topic ‘Getting value from MYSQL inside the post loop’ is closed to new replies.