CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge -> Programming

 use UserID (sessions) in SQL

Print topic Send  topic

Author Message
PeterE
Posted: 02/12/2004, 1:07 AM

What is the right syntax for something like this:

SELECT * FROM leads WHERE Dealercode="CCGetUser_ID()"


Need that in my Form Properties SQL string
Using CC, PHP, MySQL. Beginner

PE
peterr


Posts: 5971
Posted: 02/13/2004, 2:02 PM

Peter,
It's best if you do this in CC without SQL. Just specify a Table as the source of your Grid. Then in Grid properties navigate to the "Input" section and create the following Parameter:
Field: Dealercode
Variable Name: UserID
Type: Session
Data Type: Number
Operation: =

Actually, this will work automatically even if you use SQL. Therefore you can use SQL:
SELECT * FROM leads
but do not specify any Where, just the above Input Parameter.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
PeterE
Posted: 02/24/2004, 2:00 AM

PeterR,
I cannot get this to work even not when I try to follow your
information. Let try to explain what I have and what I want.

I have the following tables (I leave out the unimportant bits):

# Dealercode looks something like:
# PES (which then stands for dealer PeterSoftware)
DROP TABLE IF EXISTS dealers;
CREATE TABLE dealers (
Dealer_ID int(2) NOT NULL auto_increment,
loginnaam varchar(20) NOT NULL default '',
loginpassword varchar(20) NOT NULL default '',
login_level enum('1','2','3') NOT NULL default '1',
Dealercode char(3) default NULL,
Dealernaam varchar(40) default NULL,
Adres varchar(40) default NULL,
Postcode varchar(10) default NULL,
Plaats varchar(40) default NULL,
Land varchar(40) default '1',
PRIMARY KEY (Dealer_ID)
) TYPE=MyISAM;

# Dealercode is here a joined table, so is here a column of numbers
# refering to the table 'dealers'
# The rest is about Name and Adress etc. of customers (leads)
# So, a lead (or new customer)is automatically assigned (through a form)
# to to a specific dealer
DROP TABLE IF EXISTS leads;
CREATE TABLE leads (
LEAD_ID int(3) NOT NULL auto_increment,
Dealercode char(3) default '-',
Achternaam varchar(40) default '-',
Voornaam varchar(20) default '-',
Adres varchar(40) default '-',
Postcode varchar(10) default '-',
Plaats varchar(40) default '-',
PRIMARY KEY (LEAD_ID)
) TYPE=MyISAM;

# (in Properties > security) loginfield is loginnaam,password field is
# loginpassword
# Then a dealer (for exampl PES) logs in and looks to the leadspage
# (viewing the leads table)
# I want him to only see leads belonging to him

I've been experimenting a lot but your suggestion of useing the input
part doesn't seem to work for me. I wander why.

I must add that I am not an experienced user, PHP/CC/MySQL is still a
struggle for me, although I am learnig fast.

Any help would be appreciated.

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.