Hi,
I wanted to display users by nickname knowing only their ID.
As to be more specific: I created separate table and inserted some date (along with user ID). Obviously I want to list the table with user nickname rather than ID.
Up until now I made up with that kind of (working) thing:
$photos = mysql_query("SELECT * FROM photos")
while($list = mysql_fetch_array( $photos ))
{
$user = $wpdb->get_col("SELECT meta_value
FROM $wpdb->usermeta WHERE
meta_key = 'nickname' AND user_id = '$list[ID]'
ORDER BY user_id DESC");
echo $user[0];
}
I'm just worrying that the loop will gonna call to the database too often, am I right?
Let's say that if I will have 10000 elements in the database, than in one hour 100 users will open the page listing (calling the loop) several elements. This will generate a lot of queries.
Is there any other, simpler way of getting user nickname by ID or maybe a way to optimize the code?