WordPress.org

Support

Support » Plugins and Hacks » Hacks » [Resolved] My get_results query not returning any results

[Resolved] My get_results query not returning any results

  • Anyone got any clues please? I expect I have done something stupid.

    //Assign users to studies as authors
    global $wpdb;
    echo "Started";
    $wpdb->show_errors();
    // First get the profiles
    $result = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE  post_type='name_profile'");
    print_r ($result);
    foreach ($result as $results){
    $study_id = $results->id;
    echo "Study ID= ". $study_id;
    $study_name = $results->post_title;
    echo $study_name;
    /*$result1 = $wpdb->get_row("SELECT * FROM $wpdb->variants WHERE  study = $study_name");
    $author = $result1->number;
    $result2 = $wpdb->get_row("SELECT id FROM $wpdb->users WHERE  user_login = $author");
    $author = $result2->id;
    echo $author;
     $my_post = array(
          'ID'           => $study_id,
          'post_author' => $author
      );
    
    // Update the post into the database
      wp_update_post( $my_post );*/
    
    echo "Updated";
    }

Viewing 1 replies (of 1 total)
  • If you have a specific problem, it’s best just to post the code that is relative to it.

    What is returned when you print $result?

    Also, is there any reason you’re not using WP_Query to perform this?

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] My get_results query not returning any results’ is closed to new replies.