CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 [resolved] simple test of custom code

Print topic Send  topic

Author Message
raknuth


Posts: 67
Posted: 06/13/2011, 8:01 PM

Can some one help me to create a simple test? In the Before Show event of a CCS page, I wish to do the following:

1 - connect to my database - the name of the connection is APOG.
2 - query a table named OPPORTUNITIES for 2 fields - OPPORTUNITY_ID and OPPORTUNITY_NAME.
3 - echo the values for these 2 fields.

I am looking for proof that the connection was successful and the query was successful. I intend to place this test within a <div>, and to use this <div> inside a modal window.

Thank you.
View profile  Send private message
jjrjr2


Posts: 131
Posted: 06/13/2011, 9:03 PM

Try this..

Inside your <div> tags wherever they are in a modal window or not put this....

<div>{customcode}</div>

In your before show event after your query and after you have the data you want put this...

global $Tpl;
$Tpl->SetVar("customcode",$YourQueryValue);

Do you also need the database query code????


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us
View profile  Send private message
jjrjr2


Posts: 131
Posted: 06/13/2011, 9:34 PM

Just in case you need the Database code.

xxxxxxxxx is the name of your database connection. In your example this would be APOG.
The WHERE statement is optional. Without the WHERE statement all records are retrieved and this code below will return the 1st record.

$db= new clsDBxxxxxxxxx();
$SQL="SELECT OPPORTUNITY_ID, OPPORTUNITY_NAME FROM OPPORTUNITIES WHERE index=".$db->ToSql($ID,ccsInteger);
$db->query($SQL);

$result=$db->next_record();

if($result){
$CustomCode="Field 1 = ".$db->f("OPPORTUNITY_ID")." Field 2 = ".$db->f("OPPORTUNITY_NAME");}
else{
$CustomCode="No Data Selected";
}

$global $Tpl;
$Tpl->SetVar("customcode",$CustomCode);

That should work I think..


_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us
View profile  Send private message
raknuth


Posts: 67
Posted: 06/14/2011, 9:10 AM

I fixed it. But I can't get the forum to accept my full reply. Thanks for your help.
View profile  Send private message
raknuth


Posts: 67
Posted: 06/14/2011, 9:11 AM

$db-> new clsDBAPOG;

was required WITHOUT the parentheses.
View profile  Send private message
jjrjr2


Posts: 131
Posted: 06/16/2011, 7:03 AM

Hmmmm..

Very strange.. The new class definition usually needs the parens.

I usually declare a new database connection as

$db = new clsDBxxxxx(); .. not $db->new clsDBxxxx;

Well.. Glad it works and I was able to help a little..

John

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
Real Web Development At: http://RealWebDevelopment.us
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.

MS Access to Web

Convert MS Access to Web.
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.