CodeCharge Studio
search Register Login  

Web Reports

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 Change grid data source table name at run-time

Print topic Send  topic

Author Message
saseow

Posts: 744
Posted: 03/10/2005, 6:19 AM

I am afraid I need some help with this.

I want to change the table name that is a grid's data Source at runtime. I thought that I could simply find the SQL and change that but I can't seem to find it. The SQL which I can see in Visual Query Builder is a simple:

SELECT * FROM results_41 WHERE ( statement_category_id < 4 ) ORDER BY statement_category_id

and all I want to do is change the results_41 to another name e.g. results_68 at runtime. The 41 and 68 are actually the users ID and each user has their own result table.

Please help as this is the last hurdle in this project!

Thanks,

Trevor
View profile  Send private message
peterr


Posts: 5971
Posted: 03/10/2005, 11:33 AM

You can probably do this without modifying any code, and the solution would be the same as at http://forums.codecharge.com/posts.php?post_id=57435
Your SQL could look like this:
SELECT * FROM results_{user_id} WHERE ( statement_category_id < 4 ) ORDER BY statement_category_id
Then create SQL parameter "user_id" that maps to the session variable UserID.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
saseow

Posts: 744
Posted: 03/10/2005, 10:31 PM

Ho Peter, thanks for the reply.

I can see what you are getting at but I keep getting errors. I have not used the parameter thing before so this is what I am doing:

SELECT * FROM results_{user_id} WHERE ( statement_category_id < 4 ) ORDER BY statement_category_id

SQL Parameter:
Variable Name = user_id
Parameter Source = $userid

I get the error Database error: Invalid SQL: SELECT COUNT(*) FROM results_1 WHERE ( statement_category_id < 4 )
MySQL Error: 1146 (Table 'essa.results_1' doesn't exist)

It is obviously not picking up my session variable.

Any idea as to why thisd is wrong?

Thanks,

Trevor
View profile  Send private message
peterr


Posts: 5971
Posted: 03/10/2005, 11:10 PM

What's the name of your session variable? Usually it is UserID. The $userid doesn't look right.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
saseow

Posts: 744
Posted: 03/11/2005, 1:14 AM

It is UserID e.g.

$userid = CCGetSession("UserID","");
View profile  Send private message
saseow

Posts: 744
Posted: 03/11/2005, 6:22 AM

Peter, I got it.

Thanks for your help!

Regards,

Trevor
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.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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