By: Rob
Date: 2004-12-09
Time: 12:13
|
TBS in combination with Javascript and MySQL-menu
Hello Skrol29, and others,
I use TBS to load a table with address information. On the same page I want to use a menu which is filled from a MySQL-db by Javascript. This JS is from an 3rd party and works fine on other pages w/o TBS.
The problem is that the menu does not show. It looks like the MySQL is not read and therefore the menu not populated.
I searched on the forum and tried (I think) every suggestion. I hope you can help me out. (I left all unnecessary code out.)
The php-page that is called looks like:
<?PHP
include_once("../protected/tbs_class.php");
include_once("../protected/datafile.php");
$plaats = $_GET["plaats"] ;
$db_id = mysql_connect($db_srv,$db_usr,$db_pwd) ;
$db_ok = mysql_select_db($db_dbase,$db_id) ;
$ObjTBS = new clsTinyButStrong;
$ObjTBS->LoadTemplate("gmr_doc2_compleet.php");
$ObjTBS->MergeBlock("blk2",$db_id,"SELECT *,scholen.schoolnaam FROM gmr,scholen WHERE gmr.locatie=\"$plaats\" AND gmr.vrijgeven=\"Ja\" AND gmr.schoolnaam=scholen.index ORDER BY gmr.schoolnaam_index, gmr.namens") ;
mysql_close($db_id);
$ObjTBS->Show() ;
?>
|
The PHP-file gmr_doc2_compleet.php looks like:
[tbs_include.onload;script=gmr_header.php]
<html>
<head>
;...
;... HTML-code
;...
[tbs_include.onload;script=gmr_stm31.js]; In this file the basic Javascript for the menu is presented.
</head>
<body>
[tbs_include.onload;script=gmr_show_menu.js]; In this script the specific menu-items are loaded from the MySQL-database
;...
;... HTML-code to build the page
;...
[tbs_include.onload;file=gmr_tbs_tabel.htm]; This is the part where the TBS-details are filled in. This works fine.
;...
;... HTML-code to build the page
;...
<?php
@mysql_free_result($query);
@mysql_free_result($queryPro);
@mysql_free_result($queryPro2);
mysql_close($connection);
@mysql_free_result($query_doc);
mysql_close($connection_doc);
@mysql_free_result($query3);
mysql_close($connection3);
?>
</body>
</html>
|
The first onload calls gmr_header.php and looks like:
<?
include_once ("db.php");
$doc = $_GET["doc"] ;
$query = "select * from menu_hfd WHERE vrijgeven='Ja' AND (menudoc='5' OR menudoc='74') ORDER BY volgorde";
$connection = mysql_connect($dbhost, $dbusername, $dbpass);
$resultCat = mysql_db_query($dbname, $query);
$numrowsCat = mysql_num_rows($resultCat);
?>
|
|
By: Skrol29
Date: 2004-12-09
Time: 12:52
|
Re: TBS in combination with Javascript and MySQL-menu
Hi Rob,
What does the result of the merge look like ?
Do you have gmr_stm31.js insterted ?
Which version of TBS do you have?
Did you take care that a .js file has the <script> tags in themselves?
|
By: Rob
Date: 2004-12-09
Time: 13:11
|
Re: TBS in combination with Javascript and MySQL-menu
Hi Skrol29,
The result shows the intended page with an empty left column where the menu should show. The part where TBS is used is populated nicely (also from a MySQL db).
I did not include gmr_stm31.js as it is rather long. I send it to your email address (32kb).
I use TBS v.2.0
The <script> ... </script> tags are placed in the file.
Rob
|
By: Skrol29
Date: 2004-12-09
Time: 13:20
|
Re: TBS in combination with Javascript and MySQL-menu
[tbs_include] doesn't work with TBS 2.0.
You have to change them by [onload] or [onshow].
|
By: Rob
Date: 2004-12-09
Time: 13:26
|
Re: TBS in combination with Javascript and MySQL-menu
I tried it with v. 1.93 also. I will change the code to your suggestion.
|
By: Rob
Date: 2004-12-09
Time: 13:43
|
Re: TBS in combination with Javascript and MySQL-menu
I put the [onload] in the code. Now the resulting page starts with:
[onload;script=gmr_header.php] [onload;script=gmr_stm31.js] [onload;script=gmr_show_menu.js;getob]
|
This is with version 2.0. I also tried with getob with the first 2 scripts: no difference.
Rob
|
By: Skrol29
Date: 2004-12-09
Time: 15:04
|
Re: TBS in combination with Javascript and MySQL-menu
You should use parameter 'file' instead of 'script'.
'script' runs the file as a PHP script. But non of your sub-file are Php script. maybe gmr_header.php but I don't think so.
|
|
Posting in progress.
Please wait...
|