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

 Help needed with dynamic MySQL query.

Print topic Send  topic

Author Message
jim7567g

Posts: 38
Posted: 03/03/2005, 5:03 PM

Hello, I want to perform the following MySQL query:

SELECT {day} as hours  
FROM tech_entered_hours  
WHERE WEEK('TimeStamp',7) = WEEK('{TimeStamp}',7)  
AND user_id = {user_id}

I am trying to set the {day} variable name by pulling the value from a session variable.

Codecharge shows the following code:

  
        $this->ds->Parameters["sesday"] = CCGetSession("day");  
  
        $this->wp->AddParameter("2", "sesday", ccsText, "", "", $this->Parameters["sesday"], six, false);  
  
        $this->SQL = "SELECT " . $this->SQLValue($this->wp->GetDBValue("2"), ccsText) . " as hours " .  
        "FROM tech_entered_hours " .  
        "WHERE WEEK('TimeStamp',7) = WEEK('" . $this->SQLValue($this->wp->GetDBValue("1"), ccsDate) . "',7) " .  
        "AND user_id = " . $this->SQLValue($this->wp->GetDBValue("3"), ccsInteger) . "";  

I have tested the session variable by setting a get session event and it is working correctly and I have also checked the SQL statement to verify that it is pulling the correct records when I manually set the variables.


Any help would be greatly appreciated.

Best Regards,
_________________
Jim
View profile  Send private message
Nicole

Posts: 586
Posted: 03/04/2005, 2:34 AM

Jim,
I tried to use variables instead of field names too and used the session too. The page works just fine for me.
How exactly a form doesn’t work for you?
Where did you set a session?

And just a note. You’re using a Text type variable, so you need to surround default value "six" with double quotes.

_________________
Regards,
Nicole
View profile  Send private message
jim7567g

Posts: 38
Posted: 03/04/2005, 1:40 PM

Thanks Nicole, I'll try again.
_________________
Jim
View profile  Send private message
jim7567g

Posts: 38
Posted: 03/04/2005, 1:42 PM

Oh, I'm setting the session in the before show section of the page, not the grid.
_________________
Jim
View profile  Send private message
jim7567g

Posts: 38
Posted: 03/04/2005, 2:27 PM

Thank you again for the help, I've figured out what I've done wrong.

In the SQL statement:

WHERE WEEK('TimeStamp',7)

I have quotes around TimeStamp but it should not have them:

WHERE WEEK(TimeStamp,7)

_________________
Jim
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.

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.