Forums

Mysql query for user images (2 posts)

  1. Never
    Member
    Posted 4 years ago #

    Ok, first of all, I'm a php newbie. But I'm trying to do a gravatar-like thing where it shows an image next to everyones comment. I'm getting the images from wp_users.

    Some background info:

    I have integrated wordpress with vanilla so both use the same authentication and user table (wp_users). Vanilla uses a new row (or column? mysql newb as well) called 'Icon' that contains the avatar url for each user. I have it set up so you have to be logged in to be able to comment. So I don't need to check if the commenter has an avatar. He does by default via Vanilla.

    What i think i need to do is have a query in my comment loop that will do something like:

    if the ID equals the_author_ID than output the corresponding url that's stored in 'Icon' for that ID

    or something like that...

    i tried this following code (i basically just copied and pasted some stuff, I really don't know what i'm doing) but it doesnt work. it outputs the user id of the comment author. not what I want.


    $Auth = the_author_ID();
    $picture = $wpdb->get_results("SELECT Icon FROM $wpdb->users
    WHERE ID = '$Auth'");

    foreach ($picture as $picture) {
    echo '<img src="'.$picture.'"/>';
    }

    I'm sure someone who knows what their doing will look at that and think "what was he thinking?" :)
    So any help would be appreciated.

  2. Never
    Member
    Posted 4 years ago #

    Ok i've been reading up a little and i guess it wouldn't be

    the_author_ID.

    it should be

    $comment->user_id

    still need help with the query

Topic Closed

This topic has been closed to new replies.

About this Topic