This topic is locked
[SOLVED]

 User informations

8/9/2011 7:32:16 AM
PHPRunner General questions
S
shrun author

How do I get the information of the user logged on the screen of "list page" which lists several records?

A
Aleix 8/9/2011

Hello Shrun;
You can use the session variables like
$_SESSION["UserID"] Logged user ID
You can found information about it in the help manual. You can look for "session" and go to the session variables.
Aleix

S
shrun author 8/9/2011

Aleix, the userid I can too, but other fields not because they are not declared as session variables. For example, if I have a field in another table, how to get up this information?

C
cgphp 8/9/2011

You have to query that table using the session user var. Please, provide more info about your app.

S
shrun author 8/9/2011

I have a table called "contact" with a field called "address". The primary key is the user id, I want get the "address" of the user logged in and display it in "listpage" of table "products", as a fixed information. The table "products" have not no reference to the table "contact" .

C
cgphp 8/9/2011

Place the following code in a PHP snippet:

global $conn;

$rs = CustomQuery("SELECT contact.address as user_address FROM contact INNER JOIN users_table_name ON contact.id_user = users_table_name.id WHERE users_table_name.login_name = '".$_SESSION['UserID']."'",$conn);

$record = db_fetch_array($rs);

echo $record['user_address'];


Change the fields and tables name according to your db.
You can also create a template var and assign it the query result in the "Before display" event.

S
shrun author 8/9/2011

Ok. Thank you!!!