CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 [Solved] search form: find only records from user

Print topic Send  topic

Author Message
Markie


Posts: 251
Posted: 01/12/2009, 6:40 AM

I have a search form and a grid on one page. I want that the user of the page can only search and find his own records. At the moment, all records can be found (also those from other users). I know I can do something like this in the grid:

results grid > data source > select * from table WHERE field = CCGetUserLogin()

but this gives me the next problem:

I have followed the advice in posting http://forums.yessoftware.com/posts.php?post_id=96980

now, when I use
results grid > data source > select * from table WHERE field = CCGetUserLogin()

I still get ALL the results of the user, regardless if I have searched for anything or not. So, my question is: is there another possibility to search and find only the records of the specific user.
_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL
View profile  Send private message
datadoit
Posted: 01/12/2009, 10:42 AM

There's really no programming necessary to accomplish this. In your
results grid data source (Visual Query Builder), make the first WHERE
parameter your UserID/Session as an AND condition. Then, put all of
your other search form criteria parameters after that.
Markie


Posts: 251
Posted: 01/12/2009, 11:57 PM

Hi datadoit, thanks for pointing me the right direction. It took me a while to see an OR parameter breaks with any previous WHERE parameters. First I had this:

SELECT *
FROM table
WHERE Name = '{Expr0}'
AND Filename LIKE '{Expr1}%'
AND Filename LIKE '%{s_Filename}%'
OR File1 LIKE '%{s_Photo}%'
OR File2 LIKE '%{s_Photographer}%'

etc.

after the first OR the first parameters (WHERE Name = '{Expr0}' AND Filename LIKE '{Expr1}%' AND etc.) are not valid anymore, so I still saw all the records in my table after a search.

Now I use:

SELECT *
FROM table
WHERE Name = '{Expr0}'
AND Filename LIKE '{Expr1}%'
AND Filename LIKE '%{s_Filename}%'
OR Name = '{Expr0}'
AND Filename LIKE '{Expr1}%'
AND File1 LIKE '%{s_Photo}%'
OR Name = '{Expr0}'
AND Filename LIKE '{Expr1}%'
AND File2 LIKE '%{s_Photographer}%'

etc.

and now it works perfectly (it seems a bit like doing things double, but I think this is because the OR parameter, am I right?)

thanks again

_________________
The Netherlands, GMT+1
Tools: CCS 5.1, Windows 7, Navicat, Ultraedit
Local server: XAMPP with Apache, php and MySQL
Webserver: Windows 2008 IIS 7, php and MySQL
View profile  Send private message

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.

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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