My query works below, except that I cannot display the results, which should be "2" (results of a separate account). Instead, I get "Total Authors: ID"
//var_dump Result:
array(1) {
[0]=> object(stdClass)
["COUNT(DISTINCT writing.ID)"]=> string(1) "2″
}
}
//Code:
$authors = $wpdb->get_results("SELECT COUNT(DISTINCT writing.ID)
FROM writing
LEFT JOIN stories on writing.SID = stories.SID
LEFT JOIN wp_users ON writing.ID = wp_users.ID
WHERE (stories.SID = $the_SID)"
);
echo var_dump($authors);
print "Total Authors:" .$authors[0]->writing.ID ."<p>";
source
share