This topic is locked

Custom dropdown lists

7/28/2006 5:44:49 PM
PHPRunner General questions
G
giles author

Hi,

I'm trying to create a custom dropdown list that will display only contacts owned by the current logged in user so the user can pick email addresses for only their own contacts
Relevant table/field names are:

users table containing the userID field

contacts tables also containing userID

UserId is numeric.
In the WHERE part of the lookup wizard I've tried using one of the expressions given in the sample...
"userID=".$_SESSION["UserID"]
This gave a php error "Unkown column 'fred' in where clause". As 'fred' was the name of the user it seems I'm getting the user's name and not the numeric userID.
What should the correct expression be?

kujox 7/29/2006

The userID that is stored in the session is the name that user entered into the login screen
If you need the numeric ID, you could query the DB and place the ID in another session
and put the code in the after login successful event

G
giles author 7/31/2006

Hi Kujox,

Thanks for steering me in the right direction.
For use by others this is what made it work.... <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=10109&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
In the "After Successful Login" event insert the following customer code:
// put your custom code here

global $conn;

$rs = db_query("select userid from users where username='".$_SESSION["UserID"]

."'", $conn);

$data = db_fetch_numarray($rs);

$thisusersID = $data[0];

$_SESSION["usersIDnumber"] = $thisusersID;

}
In this case userid is a bigint field in the users table that contains the numeric identity of this user.
In the WHERE section of the lookup table wizard insert the following:
"userID=".$_SESSION["usersIDnumber"]
In this case userID is a bigint field in the clients table that identifies the user responsible for this client.
Works just the way I need it to work only showing the client for the user who is signed in...
Amazing what we can do with phprunner even with practically no knowledge of php.
Giles