This topic is locked
[SOLVED]

 show user info

11/18/2008 5:16:21 PM
PHPRunner General questions
W
wildwally author

Ok, I figured out how to get a field to display the "UserID" and the "OwnerID", for the rest of you looking for this in the future in the default tab add this:
$values["fieldname"]=$_SESSION["UserID"];
What i need help with now is changing that from the UserID or OwnerID to the owners name. In the users table I have a FIRSTNAME & LASTNAME. I want to combine the two names and display that in a field based on the UserID or OwnerID.
Can anyone help?

T
thesofa 11/19/2008

use

Concat(`FIRSTNAME`,' ',`LAASTNAME`) as 'User'



if you want that in a fiels, just use $values["fieldname"]=......

if you want it on a page but not saved, go this route instead

$user=Concat(`FIRSTNAME`,' ',`LASTNAME`;

echo $user;



if you want it all through the application, make it into a session variable, search forums for how to do this.
If you want a more formal naming system, use

$user=Concat(left(`FIRSTNAME`,1),' ',`LASTNAME`;


but I still have to ask why you are storing something more than once in a database?

you have a users table, set up a unique index of integers then when you need to record which user has done something, use the index for that person, you will find if you set it up like this and put the foreign keys into the MYSQL tables that the application will run much faster, the tables take up less storage and the data is more secure because you cannot read the data without knowing what all the numbers mean.

HTH

J
Jane 11/19/2008

Hi,
use custom format on the"View as" settings dialog on the Visual Editor tab for this purpose.

Here is just a sample:

global $conn;

$str = "select `FIRSTNAME`,`LASTNAME` from UsersTableName where UserName='".$value."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$value = $data["FIRSTNAME"]." ".$data["LASTNAME"];

W
wildwally author 11/19/2008

use

Concat(`FIRSTNAME`,' ',`LAASTNAME`) as 'User'



if you want that in a fiels, just use $values["fieldname"]=......

if you want it on a page but not saved, go this route instead

$user=Concat(`FIRSTNAME`,' ',`LASTNAME`;

echo $user;



if you want it all through the application, make it into a session variable, search forums for how to do this.
If you want a more formal naming system, use

$user=Concat(left(`FIRSTNAME`,1),' ',`LASTNAME`;


but I still have to ask why you are storing something more than once in a database?

you have a users table, set up a unique index of integers then when you need to record which user has done something, use the index for that person, you will find if you set it up like this and put the foreign keys into the MYSQL tables that the application will run much faster, the tables take up less storage and the data is more secure because you cannot read the data without knowing what all the numbers mean.

HTH


The reason for the user name is for the parties involved with the document being able to see who the salesman is. And not the username or userid. On the first example you offered I am having trouble getting it to work. First question to make sure I'm putting it in the right place, does this goe into the default value? I have tried it in many different locations and still getting errors.
$values["SALESMAN"]=Concat(`FIRSTNAME`,' ',`LAASTNAME`) as 'User'
is what i'm using, and what is the last item referring to? Do I need to change this to something in particular.

W
wildwally author 11/19/2008

Hi,

use custom format on the"View as" settings dialog on the Visual Editor tab for this purpose.

Here is just a sample:


Jane, I also tried your suggestion and recieved error also. I added the code where you suggested and changed the code to read like such

global $conn;

$str = "select `FIRSTNAME`,`LASTNAME` from users where UserName='".$value."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$value = $data["FIRSTNAME"]." ".$data["LASTNAME"];


Should I be changing the last item in this line?
$str = "select `FIRSTNAME`,`LASTNAME` from users where UserName='".$value."'";

J
Jane 11/20/2008

Hi,
you need to replace UserName with your actual field name where login name is stored.

W
wildwally author 11/20/2008

Hi,

you need to replace UserName with your actual field name where login name is stored.


I still have to be doing something wrong. The user logs in with two fields on the login screen "USERNAME" & "PASSWORD".
Here are the changes as I have understood it, and entered in where you described but nothing happens but a blank area (no errors just blank).

global $conn;

$str = "select `FIRSTNAME`,`LASTNAME` from users where USERNAME='".$value."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$value = $data["FIRSTNAME"]." ".$data["LASTNAME"];
W
wildwally author 11/20/2008



I still have to be doing something wrong. The user logs in with two fields on the login screen "USERNAME" & "PASSWORD".
Here are the changes as I have understood it, and entered in where you described but nothing happens but a blank area (no errors just blank).

global $conn;

$str = "select `FIRSTNAME`,`LASTNAME` from users where USERNAME='".$value."'";

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

$value = $data["FIRSTNAME"]." ".$data["LASTNAME"];



JANE, I did it. . .
There still is hope, let me tell you i was getting so frustrated with it until I decided to try something. The code you offered and the changes I made worked fine, when i added the original code back into the default field of read only.
Don't run off too far, I'm sure the sound of me calling for help has only begun. If there are any places you can point me to for pointers in If codes and queries that would be great.
Thanks again.