Answered: How to display a list of usernames when you have an array of USERIDs?

Post date: 2020-09-28 00:40:54
Views: 109

For future reference,

First, the query to get userid must return a flat array, not a nested one. You must use qa_db_read_all_values(qa_db_query_sub()). In the future 1.9 version, the core developers may change this.

To list the items, you can use this to list the first 3 values, the rest can be expressed as "and # others",

list($first, $second, $third) = $userids;

echo $first. ' '. $second.' '.$third. 'have answered this question';

That's why you  need a flat array, not nested.

To return the username, use this Q2A function, which is missing from official DOCS.

  • qa_userid_to_handle($first)
  • qa_userid_to_handle($second)
  • qa_userid_to_handle($third)

Similarly, to display avatars, you do MySQL queries, or exploit the Q2A functions to return avatars from $handle (ie, username).

Please click Here to read the full story.
 
Other Top and Latest Questions:
Informatica says it's not for sale, following Salesforce's reported interest in $10 billion deal
Carrier, the century-old inventor of the air conditioner, is moving on to the home heat pump
Buckle up. These stocks could see big moves in reaction to earnings this week
Supreme Court will take up the legal fight over ghost guns, firearms without serial numbers
Delta Air Lines gives staff another 5% raise, hikes starting wages to $19 an hour
Global military spending hit all-time high in 2023 after 7% jump, report finds
Stocks making the biggest moves midday: Tesla, Verizon, Paramount, Coinbase and more
The Apothecary Diaries: Chilly Apothecary
Movie: [REC] 3: Genesis
Answered: Nested comments on replies