Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

colinsp on "My get_results query not returning any results"

$
0
0

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 all articles
Browse latest Browse all 8245

Trending Articles