User’s details in the Header section

User’s details in the Header section

by Roberta Vigo -
Number of replies: 1

Hi All,

i’m creating a SQL report where each student can view the list of courses she/he has completed.

Through the template, I would like to display some user’s details (name, surname and a custom profile field) in the Header section, so not to repeat it in the record section for every row. 

Please could anybody provide me with any advice or suggestions ?

Many thanks in advance


Average of ratings: -
In reply to Roberta Vigo

Re: User’s details in the Header section

by Mik O'Leary -

I use a CONCAT statement to combine info then use UNION to join that header row to the rest of the query.

e.g.


SELECT CONCAT(usub.lastname,", ",usub.firstname,  "  ||  Last login was ",  (IF (usub.lastaccess = 0,"never",DATE_FORMAT(FROM_UNIXTIME(usub.lastaccess),'%Y-%m-%d'))),  "  ||  [Student# ",

                                usub.idnumber,  "] " ) AS 'assessment_title'

FROM prefix_user AS usub

WHERE usub.id - %%USERID%% -- shows details only for currently logged in student


UNION

   SELECT (insert query to give list of courses for this student)

   WHERE usub.id - %%USERID%% -- shows details only for currently logged in student