Wordpress Discussion

Out of context: Reply #62

  • Started
  • Last post
  • 164 Responses
  • fadein110

    Quick question - I need to pull out a value from mySQL database (custom field) in wordpress.

    I am thinking of using the code below. Unfortunately I do not have access to the site currently so I am sending an updated file to the administrator.

    Anyone know if the syntax below looks okay? I just need to pass a value to PHP variable so I can do an if/else statement:

    <?php

    $jobactive = $wpdb->get_var("SELECT Job_Active FROM activejobs");

    if ($jobactive = "2") {
    echo do_shortcode( '[contact-form-7 id="115493"]' );
    } else {
    echo do_shortcode( '[contact-form-7 id="133"]' );
    }

    ?>

    • thanks in advance by the way!fadein11
    • I believe it should be:
      if ($jobactive == 2)
      no quotes if 2 is an integer and if you're trying to check and not set the var
      spot13
    • thanks yep - picked that up now. Still doesn't work but because of the database fields :( waiting to get a copy of the database.fadein11

View thread