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

 Order CCS processes code - what am I missing???

Print topic Send  topic

Author Message
VBAjedi


Posts: 34
Posted: 02/12/2004, 11:19 AM

Not the best subject line, but the best I could think of. . . :-/

The following HTML contains a Javascript (which in turn contains four sections of PHP code) that creates a popup menu structure dynamically from a MySQL table. It works correctly when put into a simple html file (outside of CCS). It also works if pasted into the HTML view of a blank CCS page IF I point my browser to TestPage.html instead of TestPage.php .

However, the goal is to put this menu on an includable page so I can put it at the top of every page on my site under the Header include. As near as I can tell, that means I need to be able to load TestPage.php. Currently when I attempt to do so, I get an error on the line with the first PHP tag inside the Javascript.

What do I need to do to integrate this code with CCS? Do the four PHP sections need to be moved to somewhere on the "Code" tab in CCS?

Thanks, and here's the code:

  
<html>  
<head>  
</head>  
<body>  
<?  
$dbhost = "localhost"; // DB Host name  
$dbusername = "root"; // DB User  
$dbpass = "mypassword"; // DB User password  
$dbname = "testDBase"; // DB Name  
$query = "select * from menucategories";  
$connection = mysql_connect($dbhost, $dbusername, $dbpass);  
  
$resultCat = mysql_db_query($dbname, $query);  
$numrowsCat = mysql_num_rows($resultCat);  
?>  
  
<script type="text/javascript" language="JavaScript1.2" src="./Menus/stm31.js"></script>  
  
<script type="text/javascript" language="JavaScript1.2">  
<!--  
stm_bm(["menu10e2",400,"./Menus/","blank.gif",0,"","",0,0,250,0,1000,1,0,0,"","",0],this);  
stm_bp("p0",[1,4,0,0,2,3,0,7,100,"",-2,"",-2,50,0,0,"#fffff7","#fffff7","",3,1,1,"#000000"]) ;  
  
<?  
for ($i = 0; $i < $numrowsCat; $i++)  
{  
$rowCat = mysql_fetch_array($resultCat);  
$CatName = $rowCat["cat_name"];  
?>  
stm_ai("p0i0",[1,"<?=$CatName?> ","","",-1,-1,0,"","_self","","","","",0,0,0,"arrow_r.gif","arrow_r.gif",7,7,0,0,1,"#fffff7",0,"#b5bed6",0,"","",3,3,1,1,"#fffff7","#000000","#000000","#000000","8pt Verdana","8pt Verdana",0,0]);  
stm_bpx("p1","p0",[1,2,0,0,2,3,0,0]);  
<?  
$queryPro = "select * from menuitems where CID=".$rowCat["CID"];  
$resultPro = mysql_db_query($dbname, $queryPro);  
$numrowsPro = mysql_num_rows($resultPro);  
  
for ($j = 0; $j<$numrowsPro; $j++)  
{  
$rowPro = mysql_fetch_array($resultPro);  
$ProName = $rowPro["display_text"];  
$Link = $rowPro["link_string"];  
?>  
stm_ai("p1i0",[1,"<?=$ProName?> ","","",-1,-1,0,"<?=$Link?>","_self","","","","",0,0,0,"","",0,0,0,0,1,"#fffff7",0,"#b5bed6",0,"","",3,3,1,1,"#fffff7","#000000","#000000","#000000","8pt Verdana","8pt Verdana",0,0]);  
<?  
}  
?>  
stm_ep();  
<?  
}  
?>  
stm_ep();  
stm_em();  
//-->  
</script>  
</body>  
</html>  

_________________
VBAjedi
jedi at NOSPAM dot obie dot com
View profile  Send private message
peterr


Posts: 5971
Posted: 02/12/2004, 2:56 PM

You probably can put all that code in one place - in the "Before Show" event of your page or label. You will only need to conmvert the HTML part, so that the HTML is stored in a variable.

Therefore:
1. Create a Label on your page.
2. Create "Before Show" event with the above code, but convert the HTML to be stored in a variable, for example $HTML.
3. At the end of your code event set the Label's value to contain the $HTML:
$Label1->SetValue($HTML);

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
VBAjedi


Posts: 34
Posted: 02/18/2004, 10:40 AM

Got it. . .

Ended up using the Before Show event as suggested, but had to modify the code quite a bit. I converted the PHP to use the built-in CCS connection object, then used it to loop through my Category table, comparing the "Minimum security Level" of each menu category to the users security access level. I also compare the category's "Belongs to Zone" field to a superglobal session variable that indicates the site "zone" the user is currently in.

Categories that qualify are each used in a Where criteria to query the Menu Items table. I loop through the resulting dataset and repeat the security level check for each item. Menu items that qualify are used to build a Java code string (escaping characters with a backslash as needed) which I store in a variable. When I'm done looping through the tables, I bounce the Java code stored in the variable out to a label in the HTML layer and Wham-O!

When the page is loaded, dynamic menus appear for each relevant category that only show items the user is allowed to see.

I'm lovin' this stuff!
_________________
VBAjedi
jedi at NOSPAM dot obie dot com
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.