Categories > TinyButStrong general >

how to use MergeField with argument that's function

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Do Van Manh
Date: 2010-10-09
Time: 05:16

how to use MergeField with argument that's function

hi  everry body.

this's first time i user TinyButSrong i'm having problem like this

$TBS->MergeField('mergefield','mergeField',true);


function mergeField($id){
    $sql = 'select * from example where id = '.$id;
    $result = mysql_query($sql) or die(mysql_error());
    $result = mysql_fetch_array($result,MYSQL_ASSOC);
    return $result;
}

i don't know how to set $id argument for function mergeField($id). who can elp me ?
By: TomH
Date: 2010-10-09
Time: 14:52

Re: how to use MergeField with argument that's function

First,
maybe not best to name your user function the same name as the TBS function, but that's just me.

Second,
AFAIK, TBS->MergeField is intended to be used to merge a single value into a field (as opposed to a block).  Your code (select * from) implies that you are returning a row of data from the db. If so, then a normal TBS->MergeBlock might be a better choice.
Normally, use TBS->MergeBlock for one or more records from the db.

Unless I completely misunderstand what you're trying to do...

HTH,
TomH