Categories > TinyButStrong general >

call a php function in html

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: b52
Date: 2006-10-20
Time: 00:05

call a php function in html

the topic is my question :p
hope someone knows what i mean and can help me
By: Skrol29
Date: 2006-10-20
Time: 02:26

Re: call a php function in html

Hi,

You can try to put something like this into your template :
[onload;onformat=my_function]

Take care that my_function() is a custom function but must have the predefined syntax for the onformat parameter.
By: b52
Date: 2006-10-22
Time: 02:06

Re: call a php function in html

and how can i put paramaters in that function?
By: b52
Date: 2006-10-22
Time: 02:21

Re: call a php function in html

and another problem
how must i plugin the ezsql plugin
i included it but what now?
By: TomH
Date: 2006-10-22
Time: 18:11

Re: call a php function in html

Here's how I set up for running all of my TBS/ezSQL applications -- I'll cut and past from some representative files - so there may be a few disconnections - but you's get the general idea...

I use php's autoprepend feature to load the classes and initialize db connection for all pages by using the apache  .htaccess feature
php_value auto_prepend_file "\localhost\webpages\TBSapps\tbs_ezSQL.inc"

Then the tbs_ezSQL.inc looks like this:
include_once("tbs_class.php"); // WORKS FINE with PHP 5.1.4
include_once("tbs_plugin_cache.php");
include_once("tbs_plugin_html.php");
include_once("tbs_plugin_navbar.php");

include_once("tbsdb_ezsql.php"); // Skro;29's db adapter for TBS-ezSQL v2.0 compatibility

// =  Include the appropriate "ezSQL" core class  =
include_once("ez_sql_core.php"); // official Release version
include_once("ez_sql_mysql.php");
//  ezSQL as of v2.03 now includes disk caching of the db query  //$cache_timeout   = 24; //   // DEFAULT is 24 hours
//n.b  decimals accepted like: ".03"

//  Initialise database object and establish a connection 
$db_user="user";
$db_password="password";
$db_name="tbs_db"; //  set this for this application
$db_host="localhost";

$db = new ezSQL_mysql($db_user,$db_password,$db_name,$db_host);
// convert the constant to a var for usr in TBS templates
$ezsql_version = EZSQL_VERSION;

Then you're ready to create your typical TBS php file:
$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate(basename($_SERVER['SCRIPT_NAME'], ".php").".html") ;

$sql= "select id,type,position,sequence,category,categurl,descript from $head_table WHERE position='head' AND publish = 'all'  ORDER BY sequence ASC ";
$db->get_results($sql); // the ezSQL class is executed here
//$db->debug();
$TBS->MergeBlock('blk',$db);

$TBS->Show() ;

?>

Hope that helps,

By: ghjf
Date: 2008-02-03
Time: 16:34

Re: call a php function in html

fhjmf
By: hozyali
Date: 2010-08-03
Time: 23:47

Re: call a php function in html

Hi,

I would like to know the answer of b52's second question
and how can i put paramaters in that function?

I need to pass a couple of patameters to my php function.

please advise.

thanks
By: Skrol29
Date: 2010-08-03
Time: 23:52

Re: call a php function in html

Hi Hozyali,

"onformat" and "ondata" parameter can receive a value which is a custom PHP function. Nevertheless, those custom function must follow the syntax described in the manual. You cannot add arguments to such functions, their purpose is to be called by TBS when appropriate, with convenient arguments.
By: hozyali
Date: 2010-08-04
Time: 00:22

Re: call a php function in html

I understand, but I need to supply a field value type to the php function to run other php functions based on the parameter value.

Please advise with example how do I do that?

thanks for your help.
By: Skrol29
Date: 2010-08-04
Time: 01:42

Re: call a php function in html

Then use "onformat", the custom function can get the fields' parameters as an argument.
I insist you should read the manual.
http://www.tinybutstrong.com/manual.php#html_field_prm_onformat
By: hozyali
Date: 2010-08-04
Time: 08:52

Re: call a php function in html

I know onformat will work,

But I can't find an example to use for my code. that is all I need.
By: Skrol29
Date: 2010-08-04
Time: 15:30

Re: call a php function in html

By: hozyali
Date: 2010-08-04
Time: 15:36

Re: call a php function in html

its really getting complicated but it is not in my actual case.

Please see my php function below what is actually doing.

function ShowDetails($id){
$GLOBALS['initiate_the_function'];
$Query_state = "select * from ".$GLOBALS['pre_tbl']."shows WHERE art_id = '$id' ";
$rs =  mysql_query($Query_state) or die(mysql_error());
return mysql_fetch_assoc($rs);
}

above is the simple php function which returns the array of recordset.

Can you be so kind to just convert the above function into how it is required for TBS ? also with the example of template HTML which will be needed to call the above function's data.

I think this is all I need to get started with TBS.

thanks again.

Regards
Ali
By: Skrol29
Date: 2010-08-04
Time: 17:53

Re: call a php function in html

Hi,

I'm sorry you seem to be far from the first topic of this thread. It seems you'd like to merge a full data set coming from a custom function.

Since your function returns data as a PHP array, you can go to the inline examples, and see the examples named "Data -Array". They are both PHP script and template. The example gives 3 merges of array data, while you need only one.

You can notice that you can avoid your PHP function and go directly with a MySQL merge. See the example named "Data -MySQL"
By: hozyali
Date: 2010-08-04
Time: 18:15

Re: call a php function in html

I am asking because it is not working for me. I know I must be making a mistake or something wrong, and that is what I need help with.

The examples, I tried them and because they are not actually what I am doing its making trouble for me too.
By: hozyali
Date: 2010-08-04
Time: 20:46

Re: call a php function in html

Just to clarify my question more,

Yes I need full data set coming from a custom php function.

In the examples DATA - ARRAY, I studied it twice, it works itself fine, but its not working when I use MergeBlock in the php function.

That is why I need a clear and basic example of what I need so I can move on with my project and I think this will become easier for me to just copy your sample for all my future functions in this project.

Thanks again for your help.