Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.1k views
in Q2A Core by
I am trying the last 4 hours !!!! to display the number of favorite questions of each user in my advanced theme. i am using the code below:

$userfaved = qa_db_select_with_pending(qa_db_user_points_selectspec($handle));

$this->output(''.$userfaved['favorites'].' '.qa_lang_html('main/my_favorites').'');

but it doesnt work as it returns Undefined "favorites"... What i am doing wrong here ???? I am using similar code to get the number of questions a user asked and it works pretty fine !
Q2A version: 1.6.x
by
@scott @gidgreen could you please give me a direction ??
by
I'm not on the computer at the moment, but if you can't get the shortcut code of Q2A to work for you, I suggest querying the database yourself. I'll whip up something...
by
@donshakespeare thank you for responding and waiting for your answer ;)
by
moved by
What is the SQL query that returns the number of favorites a user has already favorited ???

1 Answer

+4 votes
by
selected by
 
Best answer
$userid = qa_get_logged_in_userid(); //id of currently logged in user 
$getFCount = qa_db_read_all_assoc(qa_db_query_sub("
  SELECT userid FROM demo_qa_userfavorites // "demo" is used as example
  WHERE userid = '$userid'
  "));
$getFCount = count($getFCount); //count item in array
echo $getFCount;
by
Thanks for your valuable help !! It worked like a charm...
by
Glad it worked, cheers!
...